Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jiedao-api-boot-master
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lanbaoming
jiedao-api-boot-master
Commits
c1b53931
Commit
c1b53931
authored
Aug 21, 2024
by
332784038@qq.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'order-update' into dev
parents
102847c5
555bc7f5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
403 additions
and
341 deletions
+403
-341
OrderServiceImpl.java
...dao/module/order/service/order/impl/OrderServiceImpl.java
+401
-341
OrderBackVO.java
...a/cn/iocoder/yudao/module/order/vo/order/OrderBackVO.java
+2
-0
No files found.
yudao-module-order/yudao-module-order-core/src/main/java/cn/iocoder/yudao/module/order/service/order/impl/OrderServiceImpl.java
View file @
c1b53931
...
...
@@ -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,86 +586,89 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
orderCargoControlDO
.
setIsActual
(
Boolean
.
TRUE
);
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
();
orderConsigneeDO
.
setOrderId
(
order
.
getOrderId
());
orderConsigneeDO
.
setCreator
(
creator
);
orderConsigneeDO
.
setUpdater
(
creator
);
if
(
StringUtils
.
isBlank
(
createReqVO
.
getConsigneePhone
()))
{
throw
exception
(
CONSIGNEE_PHONE_NOT_NULL
);
}
if
(
StringUtils
.
isBlank
(
createReqVO
.
getCountryCode
()))
{
throw
exception
(
CONSIGNEE_PHONE_CODE_NOT_NULL
);
}
orderConsigneeDO
.
setPhone
(
createReqVO
.
getConsigneePhone
());
orderConsigneeDO
.
setName
(
StringUtils
.
isNotBlank
(
createReqVO
.
getConsigneeName
())
?
createReqVO
.
getConsigneeName
()
:
createReqVO
.
getConsigneePhone
());
orderConsigneeDO
.
setNameEn
(
createReqVO
.
getConsigneeNameEn
());
orderConsigneeDO
.
setCountryCode
(
createReqVO
.
getCountryCode
());
orderConsigneeDO
.
setEmail
(
createReqVO
.
getConsigneeEmail
());
orderConsigneeDO
.
setCompany
(
createReqVO
.
getConsigneeCompany
());
orderConsigneeDO
.
setCompanyEn
(
createReqVO
.
getConsigneeCompanyEn
());
if
(
StringUtils
.
isBlank
(
createReqVO
.
getConsigneePhone
()))
{
throw
exception
(
CONSIGNEE_PHONE_NOT_NULL
);
}
if
(
StringUtils
.
isBlank
(
createReqVO
.
getCountryCode
()))
{
throw
exception
(
CONSIGNEE_PHONE_CODE_NOT_NULL
);
}
orderConsigneeDO
.
setPhone
(
createReqVO
.
getConsigneePhone
());
orderConsigneeDO
.
setName
(
StringUtils
.
isNotBlank
(
createReqVO
.
getConsigneeName
())
?
createReqVO
.
getConsigneeName
()
:
createReqVO
.
getConsigneePhone
());
orderConsigneeDO
.
setNameEn
(
createReqVO
.
getConsigneeNameEn
());
orderConsigneeDO
.
setCountryCode
(
createReqVO
.
getCountryCode
());
orderConsigneeDO
.
setEmail
(
createReqVO
.
getConsigneeEmail
());
orderConsigneeDO
.
setCompany
(
createReqVO
.
getConsigneeCompany
());
orderConsigneeDO
.
setCompanyEn
(
createReqVO
.
getConsigneeCompanyEn
());
orderConsigneeDO
.
setHarvestMethod
(
createReqVO
.
getHarvestMethod
());
// 收货方式
if
(
StringUtils
.
isNotBlank
(
createReqVO
.
getConsigneeAddress
()))
{
orderConsigneeDO
.
setAddress
(
createReqVO
.
getConsigneeAddress
());
}
orderConsigneeDO
.
setCountry
(
createReqVO
.
getCountry
());
orderConsigneeDO
.
setProvince
(
createReqVO
.
getProvince
());
orderConsigneeDO
.
setCity
(
createReqVO
.
getCity
());
orderConsigneeDO
.
setRelationId
(
createReqVO
.
getUserId
());
orderConsigneeDO
.
setCreateTime
(
now
);
orderConsigneeDO
.
setUpdateTime
(
now
);
if
(
StringUtils
.
isBlank
(
orderConsigneeDO
.
getPhone
())
||
StringUtils
.
isBlank
(
orderConsigneeDO
.
getCountryCode
()))
{
throw
exception
(
ORDER_CONSIGNEE_PHONE_INFO_NOT_COMPLETE
);
}
if
(
StringUtils
.
isBlank
(
orderConsigneeDO
.
getName
()))
{
throw
exception
(
ORDER_CONSIGNEE_NAME_NOT_COMPLETE
);
}
if
((
Objects
.
isNull
(
createReqVO
.
getIsCargoControl
())
||
!
createReqVO
.
getIsCargoControl
())
&&
StringUtils
.
isNotBlank
(
orderConsigneeDO
.
getCountryCode
())
&&
Objects
.
nonNull
(
dictDataRespDTO
)
&&
StringUtils
.
equals
(
dictDataRespDTO
.
getValue
(),
"11"
)
&&
StringUtils
.
equals
(
"86"
,
orderConsigneeDO
.
getCountryCode
()))
{
throw
exception
(
CONSIGNEE_PHONE_IS_EXTERNAL
);
}
try
{
String
mobileCode
=
orderConsigneeDO
.
getCountryCode
()
+
StrUtil
.
COLON
+
orderConsigneeDO
.
getPhone
();
paramValidatorService
.
validatorMobile
(
mobileCode
);
}
catch
(
Exception
e
)
{
throw
exception
(
ORDER_CONSIGNEE_PHONE_INCORRECT_FORMAT
);
}
//todo 需要判断手机号唯一性,判断规则:1.区号相同,2.先判断手机号码是否存在,然后再判断:a.如果是0开头,判断是否存在非0开头号码;b.如果非0开头,判断是否存在0开头号码
CustomerContactsDO
consignee
=
customerService
.
getUniqueOneAndValidate
(
orderConsigneeDO
.
getCountryCode
(),
orderConsigneeDO
.
getPhone
(),
null
);
orderConsigneeDO
.
setHarvestMethod
(
createReqVO
.
getHarvestMethod
());
// 收货方式
if
(
StringUtils
.
isNotBlank
(
createReqVO
.
getConsigneeAddress
()))
{
orderConsigneeDO
.
setAddress
(
createReqVO
.
getConsigneeAddress
());
}
orderConsigneeDO
.
setCountry
(
createReqVO
.
getCountry
());
orderConsigneeDO
.
setProvince
(
createReqVO
.
getProvince
());
orderConsigneeDO
.
setCity
(
createReqVO
.
getCity
());
orderConsigneeDO
.
setRelationId
(
createReqVO
.
getUserId
());
orderConsigneeDO
.
setCreateTime
(
now
);
orderConsigneeDO
.
setUpdateTime
(
now
);
if
(
StringUtils
.
isBlank
(
orderConsigneeDO
.
getPhone
())
||
StringUtils
.
isBlank
(
orderConsigneeDO
.
getCountryCode
()))
{
throw
exception
(
ORDER_CONSIGNEE_PHONE_INFO_NOT_COMPLETE
);
}
if
(
StringUtils
.
isBlank
(
orderConsigneeDO
.
getName
()))
{
throw
exception
(
ORDER_CONSIGNEE_NAME_NOT_COMPLETE
);
}
if
((
Objects
.
isNull
(
createReqVO
.
getIsCargoControl
())
||
!
createReqVO
.
getIsCargoControl
())
&&
StringUtils
.
isNotBlank
(
orderConsigneeDO
.
getCountryCode
())
&&
Objects
.
nonNull
(
dictDataRespDTO
)
&&
StringUtils
.
equals
(
dictDataRespDTO
.
getValue
(),
"11"
)
&&
StringUtils
.
equals
(
"86"
,
orderConsigneeDO
.
getCountryCode
()))
{
throw
exception
(
CONSIGNEE_PHONE_IS_EXTERNAL
);
}
try
{
String
mobileCode
=
orderConsigneeDO
.
getCountryCode
()
+
StrUtil
.
COLON
+
orderConsigneeDO
.
getPhone
();
paramValidatorService
.
validatorMobile
(
mobileCode
);
}
catch
(
Exception
e
)
{
throw
exception
(
ORDER_CONSIGNEE_PHONE_INCORRECT_FORMAT
);
}
//todo 需要判断手机号唯一性,判断规则:1.区号相同,2.先判断手机号码是否存在,然后再判断:a.如果是0开头,判断是否存在非0开头号码;b.如果非0开头,判断是否存在0开头号码
CustomerContactsDO
consignee
=
customerService
.
getUniqueOneAndValidate
(
orderConsigneeDO
.
getCountryCode
(),
orderConsigneeDO
.
getPhone
(),
null
);
if
(
Objects
.
nonNull
(
consignee
)
&&
Objects
.
nonNull
(
consignee
.
getCustomerId
()))
{
if
(
Objects
.
nonNull
(
consignee
)
&&
Objects
.
nonNull
(
consignee
.
getCustomerId
()))
{
orderConsigneeDO
.
setCustomerId
(
consignee
.
getCustomerId
());
orderConsigneeDO
.
setCustomerContactsId
(
consignee
.
getId
());
}
else
{
// 客户不存在,新增客户联系人信息 orderConsigneeDO中有值
// 20230511 收货人无客户档案时 判断发货人有无客户经理,没有 生成客户档案,进入待分配。
// 有客户经理,则暂时不生成客户档案。(放在入仓时处理)
if
(
consignorCustomerDO
==
null
||
consignorCustomerDO
.
getCustomerService
()
==
null
||
consignorCustomerDO
.
getCustomerService
()
==
0
)
{
//ecw_customer_contacts 客户联系人
//创建收货人客户
CustomerContactsDO
consigeeCustomer
=
customerService
.
createConsigeeCustomer
(
orderConsigneeDO
.
getName
(),
orderConsigneeDO
.
getCountryCode
(),
orderConsigneeDO
.
getPhone
(),
orderConsigneeDO
.
getCompany
(),
orderConsigneeDO
.
getEmail
(),
consignorCustomerDO
,
order
.
getOrderNo
());
if
(
consigeeCustomer
!=
null
)
{
orderConsigneeDO
.
setCustomerId
(
consigeeCustomer
.
getCustomerId
());
orderConsigneeDO
.
setCustomerContactsId
(
consigeeCustomer
.
getId
());
orderConsigneeDO
.
setCustomerId
(
consignee
.
getCustomerId
());
orderConsigneeDO
.
setCustomerContactsId
(
consignee
.
getId
());
}
else
{
// 客户不存在,新增客户联系人信息 orderConsigneeDO中有值
// 20230511 收货人无客户档案时 判断发货人有无客户经理,没有 生成客户档案,进入待分配。
// 有客户经理,则暂时不生成客户档案。(放在入仓时处理)
if
(
consignorCustomerDO
==
null
||
consignorCustomerDO
.
getCustomerService
()
==
null
||
consignorCustomerDO
.
getCustomerService
()
==
0
)
{
//ecw_customer_contacts 客户联系人
//创建收货人客户
CustomerContactsDO
consigeeCustomer
=
customerService
.
createConsigeeCustomer
(
orderConsigneeDO
.
getName
(),
orderConsigneeDO
.
getCountryCode
(),
orderConsigneeDO
.
getPhone
(),
orderConsigneeDO
.
getCompany
(),
orderConsigneeDO
.
getEmail
(),
consignorCustomerDO
,
order
.
getOrderNo
());
if
(
consigeeCustomer
!=
null
)
{
orderConsigneeDO
.
setCustomerId
(
consigeeCustomer
.
getCustomerId
());
orderConsigneeDO
.
setCustomerContactsId
(
consigeeCustomer
.
getId
());
}
}
}
orderConsigneeService
.
save
(
orderConsigneeDO
);
}
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,116 +794,117 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
orderConsignorDO
.
getCountryCode
()
+
orderConsignorDO
.
getPhone
());
orderBusinessService
.
createOrderControlLog
(
orderCargoControlDO
.
getOrderId
(),
1
,
"创建控货信息"
,
msg
,
0L
);
}
OrderConsigneeDO
orderConsigneeDO
=
new
OrderConsigneeDO
();
orderConsigneeDO
.
setOrderId
(
order
.
getOrderId
());
orderConsigneeDO
.
setCreator
(
creator
);
orderConsigneeDO
.
setUpdater
(
creator
);
CustomerDO
consigneeDO
=
customerService
.
getCustomer
(
createReqVO
.
getConsigneeId
());
if
(
consigneeDO
!=
null
)
{
orderConsigneeDO
.
setCompany
(
consigneeDO
.
getCompany
());
orderConsigneeDO
.
setCompanyEn
(
consigneeDO
.
getCompanyEn
());
orderConsigneeDO
.
setAddress
(
consigneeDO
.
getAddress
());
orderConsigneeDO
.
setCustomerId
(
consigneeDO
.
getId
());
CountryDO
consigneeCountryDO
=
countryService
.
getById
(
consigneeDO
.
getCountry
());
if
(
consigneeCountryDO
!=
null
)
{
orderConsignorDO
.
setCountryAbbreviation
(
consigneeCountryDO
.
getNameShort
());
}
}
else
{
orderConsigneeDO
.
setCompany
(
createReqVO
.
getConsigneeCompany
());
orderConsigneeDO
.
setCompanyEn
(
createReqVO
.
getConsigneeCompanyEn
());
orderConsigneeDO
.
setAddress
(
createReqVO
.
getConsigneeAddress
());
orderConsignorDO
.
setCountryAbbreviation
(
createReqVO
.
getCountryAbbreviation
());
}
//客户联系人
CustomerContactsDO
consigneeContactsDO
=
customerContactsService
.
getCustomerContacts
(
createReqVO
.
getConsigneeContactsId
());
if
(
null
!=
consigneeContactsDO
)
{
if
(
StringUtils
.
isBlank
(
consigneeContactsDO
.
getPhoneNew
()))
{
throw
exception
(
CONSIGNEE_PHONE_NOT_NULL
);
}
if
(
StringUtils
.
isBlank
(
consigneeContactsDO
.
getAreaCode
()))
{
throw
exception
(
CONSIGNEE_PHONE_CODE_NOT_NULL
);
}
orderConsigneeDO
.
setName
(
consigneeContactsDO
.
getName
());
orderConsigneeDO
.
setNameEn
(
consigneeContactsDO
.
getNameEn
());
orderConsigneeDO
.
setCountryCode
(
consigneeContactsDO
.
getAreaCode
());
orderConsigneeDO
.
setEmail
(
consigneeContactsDO
.
getEmail
());
orderConsigneeDO
.
setPhone
(
consigneeContactsDO
.
getPhoneNew
());
orderConsigneeDO
.
setCustomerContactsId
(
consigneeContactsDO
.
getId
());
orderConsigneeDO
.
setCustomerId
(
consigneeContactsDO
.
getCustomerId
());
}
else
{
if
(!
Objects
.
equals
(
createReqVO
.
getStatus
(),
OrderStatusEnum
.
DRAFT
.
getValue
()))
{
if
(
StringUtils
.
isBlank
(
createReqVO
.
getConsigneePhone
()))
{
OrderConsigneeDO
orderConsigneeDO
=
null
;
if
(
order
.
getIsCargoControl
()
&&
!
noConsignee
)
{
orderConsigneeDO
=
new
OrderConsigneeDO
();
orderConsigneeDO
.
setOrderId
(
order
.
getOrderId
());
orderConsigneeDO
.
setCreator
(
creator
);
orderConsigneeDO
.
setUpdater
(
creator
);
CustomerDO
consigneeDO
=
customerService
.
getCustomer
(
createReqVO
.
getConsigneeId
());
if
(
consigneeDO
!=
null
)
{
orderConsigneeDO
.
setCompany
(
consigneeDO
.
getCompany
());
orderConsigneeDO
.
setCompanyEn
(
consigneeDO
.
getCompanyEn
());
orderConsigneeDO
.
setAddress
(
consigneeDO
.
getAddress
());
orderConsigneeDO
.
setCustomerId
(
consigneeDO
.
getId
());
CountryDO
consigneeCountryDO
=
countryService
.
getById
(
consigneeDO
.
getCountry
());
if
(
consigneeCountryDO
!=
null
)
{
orderConsignorDO
.
setCountryAbbreviation
(
consigneeCountryDO
.
getNameShort
());
}
}
else
{
orderConsigneeDO
.
setCompany
(
createReqVO
.
getConsigneeCompany
());
orderConsigneeDO
.
setCompanyEn
(
createReqVO
.
getConsigneeCompanyEn
());
orderConsigneeDO
.
setAddress
(
createReqVO
.
getConsigneeAddress
());
orderConsignorDO
.
setCountryAbbreviation
(
createReqVO
.
getCountryAbbreviation
());
}
//客户联系人
CustomerContactsDO
consigneeContactsDO
=
customerContactsService
.
getCustomerContacts
(
createReqVO
.
getConsigneeContactsId
());
if
(
null
!=
consigneeContactsDO
)
{
if
(
StringUtils
.
isBlank
(
consigneeContactsDO
.
getPhoneNew
()))
{
throw
exception
(
CONSIGNEE_PHONE_NOT_NULL
);
}
if
(
StringUtils
.
isBlank
(
c
reateReqVO
.
getCountry
Code
()))
{
if
(
StringUtils
.
isBlank
(
c
onsigneeContactsDO
.
getArea
Code
()))
{
throw
exception
(
CONSIGNEE_PHONE_CODE_NOT_NULL
);
}
orderConsigneeDO
.
setName
(
consigneeContactsDO
.
getName
());
orderConsigneeDO
.
setNameEn
(
consigneeContactsDO
.
getNameEn
());
orderConsigneeDO
.
setCountryCode
(
consigneeContactsDO
.
getAreaCode
());
orderConsigneeDO
.
setEmail
(
consigneeContactsDO
.
getEmail
());
orderConsigneeDO
.
setPhone
(
consigneeContactsDO
.
getPhoneNew
());
orderConsigneeDO
.
setCustomerContactsId
(
consigneeContactsDO
.
getId
());
orderConsigneeDO
.
setCustomerId
(
consigneeContactsDO
.
getCustomerId
());
}
else
{
if
(!
Objects
.
equals
(
createReqVO
.
getStatus
(),
OrderStatusEnum
.
DRAFT
.
getValue
()))
{
if
(
StringUtils
.
isBlank
(
createReqVO
.
getConsigneePhone
()))
{
throw
exception
(
CONSIGNEE_PHONE_NOT_NULL
);
}
if
(
StringUtils
.
isBlank
(
createReqVO
.
getCountryCode
()))
{
throw
exception
(
CONSIGNEE_PHONE_CODE_NOT_NULL
);
}
}
orderConsigneeDO
.
setName
(
createReqVO
.
getConsigneeName
());
orderConsigneeDO
.
setNameEn
(
createReqVO
.
getConsigneeNameEn
());
orderConsigneeDO
.
setCountryCode
(
createReqVO
.
getCountryCode
());
orderConsigneeDO
.
setEmail
(
createReqVO
.
getConsigneeEmail
());
orderConsigneeDO
.
setPhone
(
createReqVO
.
getConsigneePhone
());
}
orderConsigneeDO
.
setName
(
createReqVO
.
getConsigneeName
());
orderConsigneeDO
.
setNameEn
(
createReqVO
.
getConsigneeNameEn
());
orderConsigneeDO
.
setCountryCode
(
createReqVO
.
getCountryCode
());
orderConsigneeDO
.
setEmail
(
createReqVO
.
getConsigneeEmail
());
orderConsigneeDO
.
setPhone
(
createReqVO
.
getConsigneePhone
());
}
orderConsigneeDO
.
setHarvestMethod
(
createReqVO
.
getHarvestMethod
());
//收货方式
orderConsigneeDO
.
setHarvestMethod
(
createReqVO
.
getHarvestMethod
());
//收货方式
if
(
StringUtils
.
isNotBlank
(
createReqVO
.
getConsigneeAddress
()))
{
orderConsigneeDO
.
setAddress
(
createReqVO
.
getConsigneeAddress
());
}
orderConsigneeDO
.
setCountry
(
createReqVO
.
getCountry
());
orderConsigneeDO
.
setProvince
(
createReqVO
.
getProvince
());
orderConsigneeDO
.
setCity
(
createReqVO
.
getCity
());
orderConsigneeDO
.
setRelationId
(
createReqVO
.
getUserId
());
orderConsigneeDO
.
setCreateTime
(
now
);
orderConsigneeDO
.
setUpdateTime
(
now
);
if
(
StringUtils
.
isNotBlank
(
createReqVO
.
getConsigneeAddress
()))
{
orderConsigneeDO
.
setAddress
(
createReqVO
.
getConsigneeAddress
());
}
orderConsigneeDO
.
setCountry
(
createReqVO
.
getCountry
());
orderConsigneeDO
.
setProvince
(
createReqVO
.
getProvince
());
orderConsigneeDO
.
setCity
(
createReqVO
.
getCity
());
orderConsigneeDO
.
setRelationId
(
createReqVO
.
getUserId
());
orderConsigneeDO
.
setCreateTime
(
now
);
orderConsigneeDO
.
setUpdateTime
(
now
);
if
(!
Objects
.
equals
(
createReqVO
.
getStatus
(),
OrderStatusEnum
.
DRAFT
.
getValue
()))
{
if
(
StringUtils
.
isBlank
(
orderConsigneeDO
.
getPhone
())
||
StringUtils
.
isBlank
(
orderConsigneeDO
.
getCountryCode
()))
{
if
(!
Objects
.
equals
(
createReqVO
.
getStatus
(),
OrderStatusEnum
.
DRAFT
.
getValue
()))
{
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
()))
{
throw
exception
(
ORDER_CONSIGNEE_NAME_NOT_COMPLETE
);
}
try
{
String
mobileCode
=
orderConsigneeDO
.
getCountryCode
()
+
StrUtil
.
COLON
+
orderConsigneeDO
.
getPhone
();
paramValidatorService
.
validatorMobile
(
mobileCode
);
}
catch
(
Exception
e
)
{
throw
exception
(
ORDER_CONSIGNEE_PHONE_INCORRECT_FORMAT
);
}
}
if
(
StringUtils
.
isBlank
(
orderConsigneeDO
.
getName
()))
{
throw
exception
(
ORDER_CONSIGNEE_NAME_NOT_COMPLETE
);
if
((
Objects
.
isNull
(
createReqVO
.
getIsCargoControl
())
||
!
createReqVO
.
getIsCargoControl
())
&&
StringUtils
.
isNotBlank
(
orderConsigneeDO
.
getCountryCode
())
&&
Objects
.
nonNull
(
dictDataRespDTO
)
&&
StringUtils
.
equals
(
dictDataRespDTO
.
getValue
(),
"11"
)
&&
StringUtils
.
equals
(
"86"
,
orderConsigneeDO
.
getCountryCode
()))
{
throw
exception
(
CONSIGNEE_PHONE_IS_EXTERNAL
);
}
try
{
String
mobileCode
=
orderConsigneeDO
.
getCountryCode
()
+
StrUtil
.
COLON
+
orderConsigneeDO
.
getPhone
();
paramValidatorService
.
validatorMobile
(
mobileCode
);
}
catch
(
Exception
e
)
{
throw
exception
(
ORDER_CONSIGNEE_PHONE_INCORRECT_FORMAT
);
if
(
StringUtils
.
isNotBlank
(
createReqVO
.
getConsigneeName
()))
{
orderConsigneeDO
.
setName
(
createReqVO
.
getConsigneeName
());
}
if
(
StringUtils
.
isNotBlank
(
createReqVO
.
getConsigneeNameEn
()))
{
orderConsigneeDO
.
setNameEn
(
createReqVO
.
getConsigneeNameEn
());
}
if
(
StringUtils
.
isNotBlank
(
createReqVO
.
getConsigneeCompany
()))
{
orderConsigneeDO
.
setCompany
(
createReqVO
.
getConsigneeCompany
());
}
if
(
StringUtils
.
isNotBlank
(
createReqVO
.
getConsigneeCompanyEn
()))
{
orderConsigneeDO
.
setCompanyEn
(
createReqVO
.
getConsigneeCompanyEn
());
}
if
(
StringUtils
.
isNotBlank
(
createReqVO
.
getConsigneeEmail
()))
{
orderConsigneeDO
.
setEmail
(
createReqVO
.
getConsigneeEmail
());
}
if
(
StringUtils
.
isNotBlank
(
orderConsigneeDO
.
getPhone
()))
{
orderConsigneeService
.
save
(
orderConsigneeDO
);
}
}
if
((
Objects
.
isNull
(
createReqVO
.
getIsCargoControl
())
||
!
createReqVO
.
getIsCargoControl
())
&&
StringUtils
.
isNotBlank
(
orderConsigneeDO
.
getCountryCode
())
&&
Objects
.
nonNull
(
dictDataRespDTO
)
&&
StringUtils
.
equals
(
dictDataRespDTO
.
getValue
(),
"11"
)
&&
StringUtils
.
equals
(
"86"
,
orderConsigneeDO
.
getCountryCode
()))
{
throw
exception
(
CONSIGNEE_PHONE_IS_EXTERNAL
);
}
if
(
StringUtils
.
isNotBlank
(
createReqVO
.
getConsigneeName
()))
{
orderConsigneeDO
.
setName
(
createReqVO
.
getConsigneeName
());
}
if
(
StringUtils
.
isNotBlank
(
createReqVO
.
getConsigneeNameEn
()))
{
orderConsigneeDO
.
setNameEn
(
createReqVO
.
getConsigneeNameEn
());
}
if
(
StringUtils
.
isNotBlank
(
createReqVO
.
getConsigneeCompany
()))
{
orderConsigneeDO
.
setCompany
(
createReqVO
.
getConsigneeCompany
());
}
if
(
StringUtils
.
isNotBlank
(
createReqVO
.
getConsigneeCompanyEn
()))
{
orderConsigneeDO
.
setCompanyEn
(
createReqVO
.
getConsigneeCompanyEn
());
}
if
(
StringUtils
.
isNotBlank
(
createReqVO
.
getConsigneeEmail
()))
{
orderConsigneeDO
.
setEmail
(
createReqVO
.
getConsigneeEmail
());
}
if
(
StringUtils
.
isNotBlank
(
orderConsigneeDO
.
getPhone
()))
{
orderConsigneeService
.
save
(
orderConsigneeDO
);
}
if
(!
Objects
.
equals
(
createReqVO
.
getStatus
(),
OrderStatusEnum
.
DRAFT
.
getValue
()))
{
...
...
@@ -1807,33 +1815,57 @@ 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
());
if
(
Objects
.
isNull
(
consigneeContactsDO
))
{
//todo 需要判断手机号唯一性,判断规则:1.区号相同,2.先判断手机号码是否存在,然后再判断:a.如果是0开头,判断是否存在非0开头号码;b.如果非0开头,判断是否存在0开头号码
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());
// 客户不存在,新增客户联系人信息 orderConsigneeDO中有值
// 20230511 收货人无客户档案时 判断发货人有无客户经理,没有 生成客户档案,进入待分配。
// 有客户经理,则暂时不生成客户档案。(放在入仓时处理)
if
(
consigneeDO
==
null
||
consigneeDO
.
getCustomerService
()
==
null
||
consigneeDO
.
getCustomerService
()
==
0
)
{
consigneeContactsDO
=
customerService
.
createConsigeeCustomer
(
orderConsigneeBackVO
.
getName
(),
orderConsigneeBackVO
.
getCountryCode
(),
orderConsigneeBackVO
.
getPhone
(),
orderConsigneeBackVO
.
getCompany
(),
orderConsigneeBackVO
.
getEmail
(),
consigneeDO
,
vo
.
getOrderNo
());
}
}
if
(
Objects
.
nonNull
(
consigneeContactsDO
))
{
this
.
compareConsigneeInfo
(
updateReqVO
,
consigneeContactsDO
,
orderConsigneeBackVO
,
applyInfoList
,
vo
,
dictDataRespDTO
);
// 客户不存在,新增客户联系人信息 orderConsigneeDO中有值
// 20230511 收货人无客户档案时 判断发货人有无客户经理,没有 生成客户档案,进入待分配。
// 有客户经理,则暂时不生成客户档案。(放在入仓时处理)
if
(
consigneeDO
==
null
||
consigneeDO
.
getCustomerService
()
==
null
||
consigneeDO
.
getCustomerService
()
==
0
)
{
consigneeContactsDO
=
customerService
.
createConsigeeCustomer
(
orderConsigneeBackVO
.
getName
(),
orderConsigneeBackVO
.
getCountryCode
(),
orderConsigneeBackVO
.
getPhone
(),
orderConsigneeBackVO
.
getCompany
(),
orderConsigneeBackVO
.
getEmail
(),
consigneeDO
,
vo
.
getOrderNo
());
}
}
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
())
{
...
...
@@ -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,71 +3002,79 @@ 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
(
Objects
.
isNull
(
orderConsigneeDO
))
{
orderConsigneeDO
=
new
OrderConsigneeDO
();
}
orderConsigneeDO
.
setOrderId
(
updateObj
.
getOrderId
());
orderConsigneeDO
.
setCreator
(
updater
);
orderConsigneeDO
.
setUpdater
(
updater
);
if
(
StringUtils
.
isBlank
(
updateReqVO
.
getConsigneePhone
()))
{
throw
exception
(
CONSIGNEE_PHONE_NOT_NULL
);
}
if
(
StringUtils
.
isBlank
(
updateReqVO
.
getCountryCode
()))
{
throw
exception
(
CONSIGNEE_PHONE_CODE_NOT_NULL
);
}
orderConsigneeDO
.
setPhone
(
updateReqVO
.
getConsigneePhone
());
orderConsigneeDO
.
setName
(
StringUtils
.
isNotBlank
(
updateReqVO
.
getConsigneeName
())
?
updateReqVO
.
getConsigneeName
()
:
updateReqVO
.
getConsigneePhone
());
orderConsigneeDO
.
setNameEn
(
Objects
.
isNull
(
updateReqVO
.
getConsigneeNameEn
())
?
""
:
updateReqVO
.
getConsigneeNameEn
());
orderConsigneeDO
.
setCountryCode
(
updateReqVO
.
getCountryCode
());
orderConsigneeDO
.
setEmail
(
updateReqVO
.
getConsigneeEmail
());
orderConsigneeDO
.
setCompany
(
updateReqVO
.
getConsigneeCompany
());
orderConsigneeDO
.
setCompanyEn
(
updateReqVO
.
getConsigneeCompanyEn
());
orderConsigneeDO
.
setHarvestMethod
(
updateReqVO
.
getHarvestMethod
());
// 收货方式
if
(
StringUtils
.
isNotBlank
(
updateReqVO
.
getConsigneeAddress
()))
{
orderConsigneeDO
.
setAddress
(
updateReqVO
.
getConsigneeAddress
());
}
orderConsigneeDO
.
setCountry
(
updateReqVO
.
getCountry
());
orderConsigneeDO
.
setProvince
(
updateReqVO
.
getProvince
());
orderConsigneeDO
.
setCity
(
updateReqVO
.
getCity
());
orderConsigneeDO
.
setRelationId
(
updateReqVO
.
getUserId
());
orderConsigneeDO
.
setCreateTime
(
now
);
orderConsigneeDO
.
setUpdateTime
(
now
);
if
(
StringUtils
.
isBlank
(
orderConsigneeDO
.
getPhone
())
||
StringUtils
.
isBlank
(
orderConsigneeDO
.
getCountryCode
()))
{
throw
exception
(
ORDER_CONSIGNEE_PHONE_INFO_NOT_COMPLETE
);
}
if
(
StringUtils
.
isBlank
(
orderConsigneeDO
.
getName
()))
{
throw
exception
(
ORDER_CONSIGNEE_NAME_NOT_COMPLETE
);
}
if
((
Objects
.
isNull
(
updateReqVO
.
getIsCargoControl
())
||
!
updateReqVO
.
getIsCargoControl
())
&&
StringUtils
.
isNotBlank
(
orderConsigneeDO
.
getCountryCode
())
&&
Objects
.
nonNull
(
dictDataRespDTO
)
&&
StringUtils
.
equals
(
"11"
,
dictDataRespDTO
.
getValue
())
&&
StringUtils
.
equals
(
"86"
,
orderConsigneeDO
.
getCountryCode
()))
{
throw
exception
(
CONSIGNEE_PHONE_IS_EXTERNAL
);
}
try
{
String
mobileCode
=
orderConsigneeDO
.
getCountryCode
()
+
StrUtil
.
COLON
+
orderConsigneeDO
.
getPhone
();
paramValidatorService
.
validatorMobile
(
mobileCode
);
}
catch
(
Exception
e
)
{
throw
exception
(
ORDER_CONSIGNEE_PHONE_INCORRECT_FORMAT
);
}
//todo 需要判断手机号唯一性,判断规则:1.区号相同,2.先判断手机号码是否存在,然后再判断:a.如果是0开头,判断是否存在非0开头号码;b.如果非0开头,判断是否存在0开头号码
CustomerContactsDO
consignee
=
customerContactsService
.
getUniqueOneAndValidate
(
orderConsigneeDO
.
getCountryCode
(),
orderConsigneeDO
.
getPhone
(),
null
);
if
(
Objects
.
nonNull
(
consignee
)
&&
Objects
.
nonNull
(
consignee
.
getCustomerId
()))
{
orderConsigneeDO
.
setCustomerId
(
consignee
.
getCustomerId
());
orderConsigneeDO
.
setCustomerContactsId
(
consignee
.
getId
());
}
else
{
// 客户不存在,新增客户联系人信息 orderConsigneeDO中有值
// 20230511 收货人无客户档案时 判断发货人有无客户经理,没有 生成客户档案,进入待分配。 有客户经理,则暂时不生成客户档案。(放在入仓时处理)
if
(
consignorCustomerDO
==
null
||
consignorCustomerDO
.
getCustomerService
()
==
null
||
consignorCustomerDO
.
getCustomerService
()
==
0
)
{
CustomerContactsDO
consigeeCustomer
=
customerService
.
createConsigeeCustomer
(
orderConsigneeDO
.
getName
(),
orderConsigneeDO
.
getCountryCode
(),
orderConsigneeDO
.
getPhone
(),
orderConsigneeDO
.
getCompany
(),
orderConsigneeDO
.
getEmail
(),
consignorCustomerDO
,
updateObj
.
getOrderNo
());
if
(
consigeeCustomer
!=
null
)
{
orderConsigneeDO
.
setCustomerId
(
consigeeCustomer
.
getCustomerId
());
orderConsigneeDO
.
setCustomerContactsId
(
consigeeCustomer
.
getId
());
if
(
updateObj
.
getIsCargoControl
()
&&
!
noConsignee
)
{
if
(
Objects
.
isNull
(
orderConsigneeDO
))
{
orderConsigneeDO
=
new
OrderConsigneeDO
();
}
orderConsigneeDO
.
setOrderId
(
updateObj
.
getOrderId
());
orderConsigneeDO
.
setCreator
(
updater
);
orderConsigneeDO
.
setUpdater
(
updater
);
if
(
StringUtils
.
isBlank
(
updateReqVO
.
getConsigneePhone
()))
{
throw
exception
(
CONSIGNEE_PHONE_NOT_NULL
);
}
if
(
StringUtils
.
isBlank
(
updateReqVO
.
getCountryCode
()))
{
throw
exception
(
CONSIGNEE_PHONE_CODE_NOT_NULL
);
}
orderConsigneeDO
.
setPhone
(
updateReqVO
.
getConsigneePhone
());
orderConsigneeDO
.
setName
(
StringUtils
.
isNotBlank
(
updateReqVO
.
getConsigneeName
())
?
updateReqVO
.
getConsigneeName
()
:
updateReqVO
.
getConsigneePhone
());
orderConsigneeDO
.
setNameEn
(
Objects
.
isNull
(
updateReqVO
.
getConsigneeNameEn
())
?
""
:
updateReqVO
.
getConsigneeNameEn
());
orderConsigneeDO
.
setCountryCode
(
updateReqVO
.
getCountryCode
());
orderConsigneeDO
.
setEmail
(
updateReqVO
.
getConsigneeEmail
());
orderConsigneeDO
.
setCompany
(
updateReqVO
.
getConsigneeCompany
());
orderConsigneeDO
.
setCompanyEn
(
updateReqVO
.
getConsigneeCompanyEn
());
orderConsigneeDO
.
setHarvestMethod
(
updateReqVO
.
getHarvestMethod
());
// 收货方式
if
(
StringUtils
.
isNotBlank
(
updateReqVO
.
getConsigneeAddress
()))
{
orderConsigneeDO
.
setAddress
(
updateReqVO
.
getConsigneeAddress
());
}
orderConsigneeDO
.
setCountry
(
updateReqVO
.
getCountry
());
orderConsigneeDO
.
setProvince
(
updateReqVO
.
getProvince
());
orderConsigneeDO
.
setCity
(
updateReqVO
.
getCity
());
orderConsigneeDO
.
setRelationId
(
updateReqVO
.
getUserId
());
orderConsigneeDO
.
setCreateTime
(
now
);
orderConsigneeDO
.
setUpdateTime
(
now
);
if
(
StringUtils
.
isBlank
(
orderConsigneeDO
.
getPhone
())
||
StringUtils
.
isBlank
(
orderConsigneeDO
.
getCountryCode
()))
{
throw
exception
(
ORDER_CONSIGNEE_PHONE_INFO_NOT_COMPLETE
);
}
if
(
StringUtils
.
isBlank
(
orderConsigneeDO
.
getName
()))
{
throw
exception
(
ORDER_CONSIGNEE_NAME_NOT_COMPLETE
);
}
if
((
Objects
.
isNull
(
updateReqVO
.
getIsCargoControl
())
||
!
updateReqVO
.
getIsCargoControl
())
&&
StringUtils
.
isNotBlank
(
orderConsigneeDO
.
getCountryCode
())
&&
Objects
.
nonNull
(
dictDataRespDTO
)
&&
StringUtils
.
equals
(
"11"
,
dictDataRespDTO
.
getValue
())
&&
StringUtils
.
equals
(
"86"
,
orderConsigneeDO
.
getCountryCode
()))
{
throw
exception
(
CONSIGNEE_PHONE_IS_EXTERNAL
);
}
try
{
String
mobileCode
=
orderConsigneeDO
.
getCountryCode
()
+
StrUtil
.
COLON
+
orderConsigneeDO
.
getPhone
();
paramValidatorService
.
validatorMobile
(
mobileCode
);
}
catch
(
Exception
e
)
{
throw
exception
(
ORDER_CONSIGNEE_PHONE_INCORRECT_FORMAT
);
}
//todo 需要判断手机号唯一性,判断规则:1.区号相同,2.先判断手机号码是否存在,然后再判断:a.如果是0开头,判断是否存在非0开头号码;b.如果非0开头,判断是否存在0开头号码
CustomerContactsDO
consignee
=
customerContactsService
.
getUniqueOneAndValidate
(
orderConsigneeDO
.
getCountryCode
(),
orderConsigneeDO
.
getPhone
(),
null
);
if
(
Objects
.
nonNull
(
consignee
)
&&
Objects
.
nonNull
(
consignee
.
getCustomerId
()))
{
orderConsigneeDO
.
setCustomerId
(
consignee
.
getCustomerId
());
orderConsigneeDO
.
setCustomerContactsId
(
consignee
.
getId
());
}
else
{
// 客户不存在,新增客户联系人信息 orderConsigneeDO中有值
// 20230511 收货人无客户档案时 判断发货人有无客户经理,没有 生成客户档案,进入待分配。 有客户经理,则暂时不生成客户档案。(放在入仓时处理)
if
(
consignorCustomerDO
==
null
||
consignorCustomerDO
.
getCustomerService
()
==
null
||
consignorCustomerDO
.
getCustomerService
()
==
0
)
{
CustomerContactsDO
consigeeCustomer
=
customerService
.
createConsigeeCustomer
(
orderConsigneeDO
.
getName
(),
orderConsigneeDO
.
getCountryCode
(),
orderConsigneeDO
.
getPhone
(),
orderConsigneeDO
.
getCompany
(),
orderConsigneeDO
.
getEmail
(),
consignorCustomerDO
,
updateObj
.
getOrderNo
());
if
(
consigeeCustomer
!=
null
)
{
orderConsigneeDO
.
setCustomerId
(
consigeeCustomer
.
getCustomerId
());
orderConsigneeDO
.
setCustomerContactsId
(
consigeeCustomer
.
getId
());
}
}
}
orderConsigneeService
.
saveOrUpdate
(
orderConsigneeDO
);
}
else
{
// 如果控货订单发货人设置了控货无收货人,则需要删除订单已有收货人
if
(
Objects
.
nonNull
(
orderConsigneeDO
)){
orderConsigneeService
.
removeById
(
orderConsigneeDO
.
getId
());
orderConsigneeDO
=
null
;
}
}
orderConsigneeService
.
saveOrUpdate
(
orderConsigneeDO
);
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,102 +3219,113 @@ 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
(
Objects
.
isNull
(
orderConsigneeDO
))
{
if
(
updateObj
.
getIsCargoControl
()
&&
!
noConsignee
)
{
orderConsigneeDO
=
new
OrderConsigneeDO
();
}
if
(
consigneeDO
!=
null
)
{
orderConsigneeDO
.
setCompany
(
consigneeDO
.
getCompany
());
orderConsigneeDO
.
setCompanyEn
(
consigneeDO
.
getCompanyEn
());
orderConsigneeDO
.
setAddress
(
consigneeDO
.
getAddress
());
CountryDO
consigneeCountryDO
=
countryService
.
getById
(
consigneeDO
.
getCountry
());
if
(
consigneeCountryDO
!=
null
)
{
orderConsignorDO
.
setCountryAbbreviation
(
consigneeCountryDO
.
getNameShort
());
}
}
else
{
orderConsigneeDO
.
setCompany
(
updateReqVO
.
getConsigneeCompany
());
orderConsigneeDO
.
setCompanyEn
(
updateReqVO
.
getConsigneeCompanyEn
());
orderConsigneeDO
.
setAddress
(
updateReqVO
.
getConsigneeAddress
());
orderConsignorDO
.
setCountryAbbreviation
(
updateReqVO
.
getCountryAbbreviation
());
}
CustomerContactsDO
consigneeContactsDO
=
customerContactsService
.
getCustomerContacts
(
updateReqVO
.
getConsigneeContactsId
());
if
(
null
!=
consigneeContactsDO
)
{
if
(
StringUtils
.
isBlank
(
consigneeContactsDO
.
getPhoneNew
()))
{
throw
exception
(
CONSIGNEE_PHONE_NOT_NULL
);
}
if
(
StringUtils
.
isBlank
(
consigneeContactsDO
.
getAreaCode
()))
{
throw
exception
(
CONSIGNEE_PHONE_CODE_NOT_NULL
);
}
orderConsigneeDO
.
setName
(
consigneeContactsDO
.
getName
());
orderConsigneeDO
.
setNameEn
(
consigneeContactsDO
.
getNameEn
());
orderConsigneeDO
.
setCountryCode
(
consigneeContactsDO
.
getAreaCode
());
orderConsigneeDO
.
setEmail
(
consigneeContactsDO
.
getEmail
());
orderConsigneeDO
.
setPhone
(
consigneeContactsDO
.
getPhoneNew
());
orderConsigneeDO
.
setCustomerContactsId
(
consigneeContactsDO
.
getId
());
orderConsigneeDO
.
setCustomerId
(
consigneeContactsDO
.
getCustomerId
());
}
else
{
if
(!
Objects
.
equals
(
updateReqVO
.
getStatus
(),
OrderStatusEnum
.
DRAFT
.
getValue
()))
{
if
(
StringUtils
.
isBlank
(
updateReqVO
.
getConsigneePhone
()))
{
if
(
Objects
.
isNull
(
orderConsigneeDO
))
{
orderConsigneeDO
=
new
OrderConsigneeDO
();
}
if
(
consigneeDO
!=
null
)
{
orderConsigneeDO
.
setCompany
(
consigneeDO
.
getCompany
());
orderConsigneeDO
.
setCompanyEn
(
consigneeDO
.
getCompanyEn
());
orderConsigneeDO
.
setAddress
(
consigneeDO
.
getAddress
());
CountryDO
consigneeCountryDO
=
countryService
.
getById
(
consigneeDO
.
getCountry
());
if
(
consigneeCountryDO
!=
null
)
{
orderConsignorDO
.
setCountryAbbreviation
(
consigneeCountryDO
.
getNameShort
());
}
}
else
{
orderConsigneeDO
.
setCompany
(
updateReqVO
.
getConsigneeCompany
());
orderConsigneeDO
.
setCompanyEn
(
updateReqVO
.
getConsigneeCompanyEn
());
orderConsigneeDO
.
setAddress
(
updateReqVO
.
getConsigneeAddress
());
orderConsignorDO
.
setCountryAbbreviation
(
updateReqVO
.
getCountryAbbreviation
());
}
CustomerContactsDO
consigneeContactsDO
=
customerContactsService
.
getCustomerContacts
(
updateReqVO
.
getConsigneeContactsId
());
if
(
null
!=
consigneeContactsDO
)
{
if
(
StringUtils
.
isBlank
(
consigneeContactsDO
.
getPhoneNew
()))
{
throw
exception
(
CONSIGNEE_PHONE_NOT_NULL
);
}
if
(
StringUtils
.
isBlank
(
updateReqVO
.
getCountryCode
())
&&
StringUtils
.
isBlank
(
updateReqVO
.
getConsigneeCountry
Code
()))
{
if
(
StringUtils
.
isBlank
(
consigneeContactsDO
.
getArea
Code
()))
{
throw
exception
(
CONSIGNEE_PHONE_CODE_NOT_NULL
);
}
orderConsigneeDO
.
setName
(
consigneeContactsDO
.
getName
());
orderConsigneeDO
.
setNameEn
(
consigneeContactsDO
.
getNameEn
());
orderConsigneeDO
.
setCountryCode
(
consigneeContactsDO
.
getAreaCode
());
orderConsigneeDO
.
setEmail
(
consigneeContactsDO
.
getEmail
());
orderConsigneeDO
.
setPhone
(
consigneeContactsDO
.
getPhoneNew
());
orderConsigneeDO
.
setCustomerContactsId
(
consigneeContactsDO
.
getId
());
orderConsigneeDO
.
setCustomerId
(
consigneeContactsDO
.
getCustomerId
());
}
else
{
if
(!
Objects
.
equals
(
updateReqVO
.
getStatus
(),
OrderStatusEnum
.
DRAFT
.
getValue
()))
{
if
(
StringUtils
.
isBlank
(
updateReqVO
.
getConsigneePhone
()))
{
throw
exception
(
CONSIGNEE_PHONE_NOT_NULL
);
}
if
(
StringUtils
.
isBlank
(
updateReqVO
.
getCountryCode
())
&&
StringUtils
.
isBlank
(
updateReqVO
.
getConsigneeCountryCode
()))
{
throw
exception
(
CONSIGNEE_PHONE_CODE_NOT_NULL
);
}
}
orderConsigneeDO
.
setCustomerContactsId
(
updateReqVO
.
getConsigneeContactsId
());
orderConsigneeDO
.
setCustomerId
(
updateReqVO
.
getConsigneeId
());
orderConsigneeDO
.
setName
(
updateReqVO
.
getConsigneeName
());
orderConsigneeDO
.
setNameEn
(
updateReqVO
.
getConsigneeNameEn
());
orderConsigneeDO
.
setCountryCode
(
Objects
.
nonNull
(
updateReqVO
.
getCountryCode
())
?
updateReqVO
.
getCountryCode
()
:
updateReqVO
.
getConsigneeCountryCode
());
orderConsigneeDO
.
setEmail
(
updateReqVO
.
getConsigneeEmail
());
orderConsigneeDO
.
setPhone
(
updateReqVO
.
getConsigneePhone
());
}
if
((
Objects
.
isNull
(
updateReqVO
.
getIsCargoControl
())
||
!
updateReqVO
.
getIsCargoControl
())
&&
StringUtils
.
isNotBlank
(
orderConsigneeDO
.
getCountryCode
())
&&
Objects
.
nonNull
(
dictDataRespDTO
)
&&
StringUtils
.
equals
(
"11"
,
dictDataRespDTO
.
getValue
())
&&
StringUtils
.
equals
(
"86"
,
orderConsigneeDO
.
getCountryCode
()))
{
throw
exception
(
CONSIGNEE_PHONE_IS_EXTERNAL
);
}
orderConsigneeDO
.
setHarvestMethod
(
updateReqVO
.
getHarvestMethod
());
// 收货方式
if
(
StringUtils
.
isNotBlank
(
updateReqVO
.
getConsigneeAddress
()))
{
orderConsigneeDO
.
setAddress
(
updateReqVO
.
getConsigneeAddress
());
}
orderConsigneeDO
.
setOrderId
(
updateObj
.
getOrderId
());
orderConsigneeDO
.
setUpdater
(
updater
);
orderConsigneeDO
.
setCountry
(
updateReqVO
.
getCountry
());
orderConsigneeDO
.
setProvince
(
updateReqVO
.
getProvince
());
orderConsigneeDO
.
setCity
(
updateReqVO
.
getCity
());
orderConsigneeDO
.
setRelationId
(
updateReqVO
.
getCustomerId
());
orderConsigneeDO
.
setUpdateTime
(
now
);
if
(!
Objects
.
equals
(
updateReqVO
.
getStatus
(),
OrderStatusEnum
.
DRAFT
.
getValue
()))
{
if
(
StringUtils
.
isBlank
(
orderConsigneeDO
.
getPhone
())
||
StringUtils
.
isBlank
(
orderConsigneeDO
.
getCountryCode
()))
{
throw
exception
(
ORDER_CONSIGNEE_PHONE_INFO_NOT_COMPLETE
);
}
if
(
StringUtils
.
isBlank
(
orderConsigneeDO
.
getName
()))
{
throw
exception
(
ORDER_CONSIGNEE_NAME_NOT_COMPLETE
);
}
try
{
String
mobileCode
=
orderConsigneeDO
.
getCountryCode
()
+
StrUtil
.
COLON
+
orderConsigneeDO
.
getPhone
();
paramValidatorService
.
validatorMobile
(
mobileCode
);
}
catch
(
Exception
e
)
{
throw
exception
(
ORDER_CONSIGNEE_PHONE_INCORRECT_FORMAT
);
}
}
orderConsigneeDO
.
setCustomerContactsId
(
updateReqVO
.
getConsigneeContactsId
());
orderConsigneeDO
.
setCustomerId
(
updateReqVO
.
getConsigneeId
());
orderConsigneeDO
.
setName
(
updateReqVO
.
getConsigneeName
());
orderConsigneeDO
.
setNameEn
(
updateReqVO
.
getConsigneeNameEn
());
orderConsigneeDO
.
setCountryCode
(
Objects
.
nonNull
(
updateReqVO
.
getCountryCode
())
?
updateReqVO
.
getCountryCode
()
:
updateReqVO
.
getConsigneeCountryCode
());
orderConsigneeDO
.
setEmail
(
updateReqVO
.
getConsigneeEmail
());
orderConsigneeDO
.
setPhone
(
updateReqVO
.
getConsigneePhone
());
}
if
((
Objects
.
isNull
(
updateReqVO
.
getIsCargoControl
())
||
!
updateReqVO
.
getIsCargoControl
())
&&
StringUtils
.
isNotBlank
(
orderConsigneeDO
.
getCountryCode
())
&&
Objects
.
nonNull
(
dictDataRespDTO
)
&&
StringUtils
.
equals
(
"11"
,
dictDataRespDTO
.
getValue
())
&&
StringUtils
.
equals
(
"86"
,
orderConsigneeDO
.
getCountryCode
()))
{
throw
exception
(
CONSIGNEE_PHONE_IS_EXTERNAL
);
}
orderConsigneeDO
.
setHarvestMethod
(
updateReqVO
.
getHarvestMethod
());
// 收货方式
if
(
StringUtils
.
isNotBlank
(
updateReqVO
.
getConsigneeAddress
()))
{
orderConsigneeDO
.
setAddress
(
updateReqVO
.
getConsigneeAddress
());
}
orderConsigneeDO
.
setOrderId
(
updateObj
.
getOrderId
());
orderConsigneeDO
.
setUpdater
(
updater
);
orderConsigneeDO
.
setCountry
(
updateReqVO
.
getCountry
());
orderConsigneeDO
.
setProvince
(
updateReqVO
.
getProvince
());
orderConsigneeDO
.
setCity
(
updateReqVO
.
getCity
());
orderConsigneeDO
.
setRelationId
(
updateReqVO
.
getCustomerId
());
orderConsigneeDO
.
setUpdateTime
(
now
);
if
(!
Objects
.
equals
(
updateReqVO
.
getStatus
(),
OrderStatusEnum
.
DRAFT
.
getValue
()))
{
if
(
StringUtils
.
isBlank
(
orderConsigneeDO
.
getPhone
())
||
StringUtils
.
isBlank
(
orderConsigneeDO
.
getCountryCode
()))
{
throw
exception
(
ORDER_CONSIGNEE_PHONE_INFO_NOT_COMPLETE
);
if
(
StringUtils
.
isNotBlank
(
updateReqVO
.
getConsigneeName
()))
{
orderConsigneeDO
.
setName
(
updateReqVO
.
getConsigneeName
());
}
if
(
StringUtils
.
is
Blank
(
orderConsigneeDO
.
getName
()))
{
throw
exception
(
ORDER_CONSIGNEE_NAME_NOT_COMPLETE
);
if
(
StringUtils
.
is
NotBlank
(
updateReqVO
.
getConsigneeNameEn
()))
{
orderConsigneeDO
.
setNameEn
(
updateReqVO
.
getConsigneeNameEn
()
);
}
try
{
String
mobileCode
=
orderConsigneeDO
.
getCountryCode
()
+
StrUtil
.
COLON
+
orderConsigneeDO
.
getPhone
();
paramValidatorService
.
validatorMobile
(
mobileCode
);
}
catch
(
Exception
e
)
{
throw
exception
(
ORDER_CONSIGNEE_PHONE_INCORRECT_FORMAT
);
if
(
StringUtils
.
isNotBlank
(
updateReqVO
.
getConsigneeCompany
()))
{
orderConsigneeDO
.
setCompany
(
updateReqVO
.
getConsigneeCompany
());
}
}
if
(
StringUtils
.
isNotBlank
(
updateReqVO
.
getConsigneeName
()))
{
orderConsigneeDO
.
setName
(
updateReqVO
.
getConsigneeName
());
}
if
(
StringUtils
.
isNotBlank
(
updateReqVO
.
getConsigneeNameEn
()))
{
orderConsigneeDO
.
setNameEn
(
updateReqVO
.
getConsigneeNameEn
());
}
if
(
StringUtils
.
isNotBlank
(
updateReqVO
.
getConsigneeCompany
()))
{
orderConsigneeDO
.
setCompany
(
updateReqVO
.
getConsigneeCompany
());
}
if
(
StringUtils
.
isNotBlank
(
updateReqVO
.
getConsigneeCompanyEn
()))
{
orderConsigneeDO
.
setCompanyEn
(
updateReqVO
.
getConsigneeCompanyEn
());
}
if
(
StringUtils
.
isNotBlank
(
updateReqVO
.
getConsigneeEmail
()))
{
orderConsigneeDO
.
setEmail
(
updateReqVO
.
getConsigneeEmail
());
}
if
(
StringUtils
.
isNotBlank
(
orderConsigneeDO
.
getPhone
()))
{
orderConsigneeService
.
saveOrUpdate
(
orderConsigneeDO
);
if
(
StringUtils
.
isNotBlank
(
updateReqVO
.
getConsigneeCompanyEn
()))
{
orderConsigneeDO
.
setCompanyEn
(
updateReqVO
.
getConsigneeCompanyEn
());
}
if
(
StringUtils
.
isNotBlank
(
updateReqVO
.
getConsigneeEmail
()))
{
orderConsigneeDO
.
setEmail
(
updateReqVO
.
getConsigneeEmail
());
}
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
()))
{
...
...
@@ -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
);
orderConsigneeService
.
updateById
(
consigneeDO
);
// 控货订单发货人无收货人属性变动,需要清空订单收货人信息
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
);
}
...
...
yudao-module-order/yudao-module-order-core/src/main/java/cn/iocoder/yudao/module/order/vo/order/OrderBackVO.java
View file @
c1b53931
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment