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
f7df0151
Commit
f7df0151
authored
Sep 14, 2024
by
yanghao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: 客户合并中订单相关合并和日志纪录
parent
f3f9469d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
133 additions
and
6 deletions
+133
-6
20240914.sql
sql/v2.1/20240914.sql
+2
-0
CustomerController.java
...ustomer/controller/admin/customer/CustomerController.java
+54
-2
CustomerOperateTypeEnum.java
...coder/yudao/module/ecw/enums/CustomerOperateTypeEnum.java
+5
-0
OrderApi.java
.../main/java/cn/iocoder/boot/module/order/api/OrderApi.java
+9
-0
OrderApiImpl.java
.../java/cn/iocoder/yudao/module/order/api/OrderApiImpl.java
+63
-4
No files found.
sql/v2.1/20240914.sql
0 → 100644
View file @
f7df0151
INSERT
INTO
`system_dict_data`
(
`sort`
,
`value`
,
`label`
,
`label_en`
,
`dict_type`
,
`status`
,
`color_type`
,
`css_class`
,
`remark`
,
`creator`
,
`create_time`
,
`updater`
,
`update_time`
,
`deleted`
)
VALUES
(
33
,
'33'
,
'客户合并'
,
'Customer Merge'
,
'customer_operate_type'
,
0
,
'default'
,
''
,
NULL
,
'1'
,
now
(),
'115'
,
now
(),
b
'0'
);
yudao-module-customer/yudao-module-customer-rest/src/main/java/cn/iocoder/yudao/module/customer/controller/admin/customer/CustomerController.java
View file @
f7df0151
...
...
@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.customer.controller.admin.customer;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.iocoder.boot.module.order.api.OrderApi
;
import
cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil
;
import
cn.iocoder.yudao.framework.common.pojo.CommonResult
;
import
cn.iocoder.yudao.framework.common.pojo.PageResult
;
...
...
@@ -13,6 +14,7 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import
cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX
;
import
cn.iocoder.yudao.framework.mybatis.core.vo.PageVO
;
import
cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog
;
import
cn.iocoder.yudao.framework.security.core.LoginUser
;
import
cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils
;
import
cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils
;
import
cn.iocoder.yudao.module.customer.convert.customer.CustomerConvert
;
...
...
@@ -38,6 +40,7 @@ import cn.iocoder.yudao.module.customer.service.customerContacts.CustomerContact
import
cn.iocoder.yudao.module.customer.service.customerCredit.CustomerCreditService
;
import
cn.iocoder.yudao.module.customer.service.customerLevel.CustomerLevelService
;
import
cn.iocoder.yudao.module.customer.service.customerLevelLog.CustomerLevelLogServiceImpl
;
import
cn.iocoder.yudao.module.customer.service.customerOperateLog.CustomerOperateLogService
;
import
cn.iocoder.yudao.module.customer.service.customerPublicCatchLog.CustomerPublicCatchLogService
;
import
cn.iocoder.yudao.module.customer.service.zhongPao.ZhongPaoService
;
import
cn.iocoder.yudao.module.customer.vo.customer.customerContacts.CustomerContactsCreateReqVO
;
...
...
@@ -46,6 +49,7 @@ import cn.iocoder.yudao.module.customer.vo.customer.customerContacts.CustomerCon
import
cn.iocoder.yudao.module.customer.vo.customer.vo.*
;
import
cn.iocoder.yudao.module.customer.vo.customerBank.CustomerBankBackVO
;
import
cn.iocoder.yudao.module.customer.vo.customerBank.CustomerBankQueryVO
;
import
cn.iocoder.yudao.module.customer.vo.customerOperateLog.CustomerOperateLogCreateReqVO
;
import
cn.iocoder.yudao.module.ecw.api.paramValid.ParamValidatorApi
;
import
cn.iocoder.yudao.module.ecw.enums.CustomerContactsDefaultEnum
;
import
cn.iocoder.yudao.module.ecw.enums.CustomerCreateFromEnum
;
...
...
@@ -115,6 +119,9 @@ public class CustomerController {
@Resource
private
AdminUserApi
adminUserApi
;
@Resource
private
OrderApi
orderApi
;
@Resource
private
CountryService
countryService
;
...
...
@@ -174,6 +181,9 @@ public class CustomerController {
@Resource
private
CustomerLevelLogServiceImpl
customerLevelLogService
;
@Resource
private
CustomerOperateLogService
customerOperateLogService
;
public
CustomerController
()
{
}
...
...
@@ -450,9 +460,51 @@ public class CustomerController {
//合并信用日志 8
customerService
.
doMergeCustomerCreditLog
(
customerDO1
.
getId
(),
customerDO2
.
getId
());
//合并订单
orderApi
.
mergeOrder
(
customerDO1
.
getId
(),
customerDO2
.
getId
());
//合并操作日志 9
customerService
.
doMergeCustomerOperateLog
(
customerDO1
.
getId
(),
customerDO2
.
getId
());
// customerService.doMergeCustomerOperateLog(customerDO1.getId(),
// customerDO2.getId());
// 纪录客户合并日志
LoginUser
loginUser
=
SecurityFrameworkUtils
.
getLoginUser
();
CustomerOperateLogCreateReqVO
customerOperateLogCreateReqVO
=
new
CustomerOperateLogCreateReqVO
()
.
setOperator
(
loginUser
==
null
?
null
:
loginUser
.
getId
())
.
setOperatorName
(
loginUser
==
null
?
null
:
loginUser
.
getNickname
())
.
setCustomerId
(
customerDO1
.
getId
())
.
setNumber
(
customerDO1
.
getNumber
())
.
setName
(
customerDO1
.
getName
())
.
setOldCustomerService
(
null
)
.
setNewCustomerService
(
customerDO1
.
getCustomerService
())
.
setOldEstimateEnterOpenSeaTime
(
null
)
.
setNewEstimateEnterOpenSeaTime
(
customerDO1
.
getEstimateEnterOpenSeaTime
())
.
setOrderId
(
null
)
.
setOrderNo
(
null
)
.
setOperateType
(
CustomerOperateTypeEnum
.
CUSTOMER_MERGE
.
getValue
())
.
setRemark
(
String
.
format
(
"将客户【%d-%s-%s】合并到此客户"
,
customerDO2
.
getId
(),
customerDO2
.
getNumber
(),
customerDO2
.
getName
()));
customerOperateLogService
.
createOperateLog
(
customerOperateLogCreateReqVO
);
//纪录被删除的客户的日志
CustomerOperateLogCreateReqVO
customerOperateLogCreateReqVO2
=
new
CustomerOperateLogCreateReqVO
()
.
setOperator
(
loginUser
==
null
?
null
:
loginUser
.
getId
())
.
setOperatorName
(
loginUser
==
null
?
null
:
loginUser
.
getNickname
())
.
setCustomerId
(
customerDO2
.
getId
())
.
setNumber
(
customerDO2
.
getNumber
())
.
setName
(
customerDO2
.
getName
())
.
setOldCustomerService
(
null
)
.
setNewCustomerService
(
customerDO2
.
getCustomerService
())
.
setOldEstimateEnterOpenSeaTime
(
null
)
.
setNewEstimateEnterOpenSeaTime
(
customerDO2
.
getEstimateEnterOpenSeaTime
())
.
setOrderId
(
null
)
.
setOrderNo
(
null
)
.
setOperateType
(
CustomerOperateTypeEnum
.
CUSTOMER_MERGE
.
getValue
())
.
setRemark
(
String
.
format
(
"将此客户合并到主客户【%d-%s-%s】"
,
customerDO1
.
getId
(),
customerDO1
.
getNumber
(),
customerDO1
.
getName
()));
customerOperateLogService
.
createOperateLog
(
customerOperateLogCreateReqVO2
);
return
true
;
}
...
...
yudao-module-ecw/yudao-module-ecw-api/src/main/java/cn/iocoder/yudao/module/ecw/enums/CustomerOperateTypeEnum.java
View file @
f7df0151
...
...
@@ -67,6 +67,11 @@ public enum CustomerOperateTypeEnum {
CUSTOMER_UPDATE_SETUP
(
32
,
"设置客户设置"
),
CUSTOMER_MERGE
(
33
,
"客户合并"
),
DELETE
(
100
,
"删除"
),
...
...
yudao-module-order/yudao-module-order-api/src/main/java/cn/iocoder/boot/module/order/api/OrderApi.java
View file @
f7df0151
...
...
@@ -21,4 +21,13 @@ public interface OrderApi {
* 根据订单id获取所有订单项
*/
List
<
OrderItemRespDTO
>
getOrderItemsByOrderId
(
Long
orderId
);
/**
* 合并订单
* @param customerIdSaved 保留客户id
* @param customerIdDeleted 删除客户id
* @return 是否合并成功
*/
boolean
mergeOrder
(
Long
customerIdSaved
,
Long
customerIdDeleted
);
}
yudao-module-order/yudao-module-order-core/src/main/java/cn/iocoder/yudao/module/order/api/OrderApiImpl.java
View file @
f7df0151
...
...
@@ -3,16 +3,16 @@ package cn.iocoder.yudao.module.order.api;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.iocoder.boot.module.order.api.OrderApi
;
import
cn.iocoder.boot.module.order.api.dto.*
;
import
cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX
;
import
cn.iocoder.yudao.module.customer.dal.dataobject.customer.CustomerDO
;
import
cn.iocoder.yudao.module.customer.service.customer.CustomerService
;
import
cn.iocoder.yudao.module.order.convert.orderConsignor.OrderConsignorConvert
;
import
cn.iocoder.yudao.module.order.dal.dataobject.order.OrderDO
;
import
cn.iocoder.yudao.module.order.dal.dataobject.orderConsignee.OrderConsigneeDO
;
import
cn.iocoder.yudao.module.order.dal.dataobject.orderConsignor.OrderConsignorDO
;
import
cn.iocoder.yudao.module.order.dal.dataobject.orderItem.OrderItemDO
;
import
cn.iocoder.yudao.module.order.dal.dataobject.orderObjective.OrderObjectiveDO
;
import
cn.iocoder.yudao.module.order.service.order.OrderConsigneeService
;
import
cn.iocoder.yudao.module.order.service.order.OrderConsignorService
;
import
cn.iocoder.yudao.module.order.service.order.OrderObjectiveService
;
import
cn.iocoder.yudao.module.order.service.order.OrderService
;
import
cn.iocoder.yudao.module.order.service.order.*
;
import
cn.iocoder.yudao.module.order.service.order.impl.OrderItemServiceImpl
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
org.springframework.beans.BeanUtils
;
...
...
@@ -20,6 +20,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.validation.annotation.Validated
;
import
javax.annotation.Resource
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.stream.Collectors
;
...
...
@@ -30,6 +31,10 @@ public class OrderApiImpl implements OrderApi {
@Resource
private
OrderService
orderService
;
@Resource
private
OrderBusinessService
orderBusinessService
;
@Resource
private
CustomerService
customerService
;
@Resource
private
OrderObjectiveService
objectiveService
;
@Resource
private
OrderConsigneeService
orderConsigneeService
;
...
...
@@ -92,4 +97,58 @@ public class OrderApiImpl implements OrderApi {
}
return
null
;
}
@Override
public
boolean
mergeOrder
(
Long
customerIdSaved
,
Long
customerIdDeleted
)
{
CustomerDO
customerDeleted
=
customerService
.
getById
(
customerIdDeleted
);
CustomerDO
customerSaved
=
customerService
.
getById
(
customerIdSaved
);
// 将customerId=customerIdDeleted的订单的customerId更新为customerIdSaved
List
<
OrderDO
>
list
=
orderService
.
selectList
(
new
LambdaQueryWrapperX
<
OrderDO
>().
eq
(
OrderDO:
:
getCustomerId
,
customerIdDeleted
));
if
(
CollectionUtil
.
isNotEmpty
(
list
))
{
for
(
OrderDO
order
:
list
)
{
order
.
setCustomerId
(
customerIdSaved
);
order
.
setUpdateTime
(
new
Date
());
orderService
.
updateById
(
order
);
// 保存操作日志
orderBusinessService
.
addOrderOperateLog
(
order
.
getOrderId
(),
"合并客户-归属人"
,
String
.
format
(
"将此订单的客户由【%d-%s-%s】合并为【%d-%s-%s】"
,
customerDeleted
.
getId
(),
customerDeleted
.
getNumber
(),
customerDeleted
.
getName
(),
customerSaved
.
getId
(),
customerSaved
.
getNumber
(),
customerSaved
.
getName
()));
}
}
// 修改收货人
List
<
OrderConsigneeDO
>
orderConsigneeDOList
=
orderConsigneeService
.
selectList
(
new
LambdaQueryWrapperX
<
OrderConsigneeDO
>().
eq
(
OrderConsigneeDO:
:
getCustomerId
,
customerIdDeleted
));
if
(
CollectionUtil
.
isNotEmpty
(
orderConsigneeDOList
))
{
for
(
OrderConsigneeDO
orderConsigneeDO
:
orderConsigneeDOList
)
{
orderConsigneeDO
.
setCustomerId
(
customerIdSaved
);
orderConsigneeDO
.
setCustomerNumber
(
customerSaved
.
getNumber
());
orderConsigneeService
.
updateById
(
orderConsigneeDO
);
// 保存操作日志
orderBusinessService
.
addOrderOperateLog
(
orderConsigneeDO
.
getOrderId
(),
"合并客户-收货人"
,
String
.
format
(
"将此订单的收货人客户由【%d-%s-%s】合并为【%d-%s-%s】"
,
customerDeleted
.
getId
(),
customerDeleted
.
getNumber
(),
customerDeleted
.
getName
(),
customerSaved
.
getId
(),
customerSaved
.
getNumber
(),
customerSaved
.
getName
()));
}
}
// 修改发货人
List
<
OrderConsignorDO
>
orderConsignorDOList
=
orderConsignorService
.
selectList
(
new
LambdaQueryWrapperX
<
OrderConsignorDO
>().
eq
(
OrderConsignorDO:
:
getCustomerId
,
customerIdDeleted
));
if
(
CollectionUtil
.
isNotEmpty
(
orderConsignorDOList
))
{
for
(
OrderConsignorDO
orderConsignorDO
:
orderConsignorDOList
)
{
orderConsignorDO
.
setCustomerId
(
customerIdSaved
);
orderConsignorDO
.
setCustomerNumber
(
customerSaved
.
getNumber
());
orderConsignorService
.
updateById
(
orderConsignorDO
);
// 保存操作日志
orderBusinessService
.
addOrderOperateLog
(
orderConsignorDO
.
getOrderId
(),
"合并客户-发货人"
,
String
.
format
(
"将此订单的发货人客户由【%d-%s-%s】合并为【%d-%s-%s】"
,
customerDeleted
.
getId
(),
customerDeleted
.
getNumber
(),
customerDeleted
.
getName
(),
customerSaved
.
getId
(),
customerSaved
.
getNumber
(),
customerSaved
.
getName
()));
}
}
return
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