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
53b1aa90
Commit
53b1aa90
authored
Oct 31, 2024
by
332784038@qq.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
校验订单审批业务互斥逻辑
parent
05ecb0da
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
163 additions
and
31 deletions
+163
-31
OrderApprovalTypeCheckEvent.java
.../apollo/core/event/Order/OrderApprovalTypeCheckEvent.java
+29
-0
OrderApprovalMapper.java
.../module/order/dal/mysql/approval/OrderApprovalMapper.java
+21
-0
OrderApprovalTypeEnum.java
...coder/yudao/module/order/enums/OrderApprovalTypeEnum.java
+46
-31
OrderApprovalTypeCheckListener.java
...module/order/listener/OrderApprovalTypeCheckListener.java
+52
-0
OrderApprovalService.java
...o/module/order/service/approval/OrderApprovalService.java
+9
-0
OrderApprovalServiceImpl.java
...dule/order/service/approval/OrderApprovalServiceImpl.java
+6
-0
No files found.
yudao-framework/yudao-spring-boot-starter-config/src/main/java/cn/iocoder/yudao/framework/apollo/core/event/Order/OrderApprovalTypeCheckEvent.java
0 → 100644
View file @
53b1aa90
package
cn
.
iocoder
.
yudao
.
framework
.
apollo
.
core
.
event
.
Order
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
@Data
@AllArgsConstructor
public
class
OrderApprovalTypeCheckEvent
{
/**
* 订单id
*/
private
Long
orderId
;
/**
* 订单项id
*/
private
Long
orderItemId
;
/**
* 订单审批类型 {@link cn.iocoder.yudao.module.order.enums.OrderApprovalTypeEnum}
*/
private
Integer
approvalType
;
/**
* 是否包含互斥审批类型: true 包含互斥审批或相同的审批不能进行重复审批 false 是没有包含互斥审批类型和当前审批类型
*/
private
Boolean
result
;
}
yudao-module-order/yudao-module-order-core/src/main/java/cn/iocoder/yudao/module/order/dal/mysql/approval/OrderApprovalMapper.java
View file @
53b1aa90
...
...
@@ -200,4 +200,25 @@ public interface OrderApprovalMapper extends AbstractMapper<OrderApprovalDO> {
"</script>"
})
List
<
OrderApprovalDO
>
approvalListBytTypeAndStatus
(
@Param
(
"orderId"
)
Long
orderId
,
@Param
(
"typeList"
)
List
<
Integer
>
typeList
,
@Param
(
"status"
)
Integer
status
);
@ResultType
(
OrderApprovalDO
.
class
)
@Select
({
"<script>"
,
"select"
,
" count(1),"
,
"from ecw_order_approval a"
,
"where "
,
"a.order_id = #{orderId} "
,
"<when test = 'types != null && types.size() > 0'>"
,
"and a.type in <foreach item='type' index='index' collection='typeList' open='(' separator=',' close=')'>#{type}</foreach> "
,
"</when>"
,
"<when test = 'orderItemId != null'>"
,
"and (a.order_item_id is null or (a.order_item_id is not null && a.order_item_id = #{orderItemId})) "
,
"</when>"
,
"and a.status = 1 "
,
"order by a.order_approval_id desc"
,
"</script>"
})
long
countProcessingApproval
(
@Param
(
"orderId"
)
Long
orderId
,
@Param
(
"orderItemId"
)
Long
orderItemId
,
@Param
(
"types"
)
List
<
Integer
>
types
);
}
yudao-module-order/yudao-module-order-core/src/main/java/cn/iocoder/yudao/module/order/enums/OrderApprovalTypeEnum.java
View file @
53b1aa90
...
...
@@ -5,54 +5,65 @@ import lombok.AllArgsConstructor;
import
lombok.Getter
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.List
;
@AllArgsConstructor
@Getter
public
enum
OrderApprovalTypeEnum
{
DISCOUNT_APPLY
(
1
,
"优惠申请"
),
ADMIN_DISCOUNT
(
2
,
"管理优惠"
),
COMMISSION_SET
(
3
,
"佣金设置"
),
WEIGHT_DISCOUNT
(
4
,
"重货优惠"
),
BUBBLE_DISCOUNT
(
5
,
"泡货优惠"
),
ORDER_SPLIT
(
6
,
"拆单"
),
ORDER_CARGO_CONTROL_PICK_UPDATE
(
7
,
"控货订单放货修改"
),
ORDER_CARGO_CONTROL_PICK_ANTI_CHECKING
(
8
,
"控货订单反复核"
),
seasoning_condiments
(
9
,
"调货"
),
order_cargo_control_cancel_pick
(
10
,
"取消放货"
),
merge_order
(
11
,
"合单"
),
expense_apply
(
12
,
"费用申请"
),
WAREHOUSE_ADJUST
(
13
,
"调仓"
),
ORDER_UPDATE
(
14
,
"订单修改"
),
WAREHOUSE_UPDATE
(
22
,
"入仓修改"
),
WAREHOUSE_ROLLBACK
(
23
,
"退仓"
),
pre_install_back
(
24
,
"预装反审"
),
closure_back
(
25
,
"封柜反审"
),
unloading_cabinet_back
(
26
,
"卸柜反审"
),
customs_exit
(
27
,
"报关审批"
),
ORDER_SPLIT_REVOKE
(
28
,
"撤销订单拆单"
),
BUBBLE_WEIGHT_SPECIAL_DISCOUNT
(
29
,
"泡重特价优惠"
),
DISCOUNT_APPLY
(
1
,
"优惠申请"
,
Arrays
.
asList
(
2
,
6
,
11
,
14
,
23
,
28
,
31
,
32
)),
// 管理优惠(当前商品有在途申请)/拆单申请/合单申请/订单修改/退仓/撤销拆单审批/批量优惠申请(当前商品有在途申请)/批量管理折扣申请(当前商品有在途申请)
ADMIN_DISCOUNT
(
2
,
"管理优惠"
,
Arrays
.
asList
(
1
,
6
,
11
,
14
,
23
,
28
,
31
,
32
)),
// 拆单申请/合单申请/订单修改/退仓/撤销拆单审批/批量优惠申请(当前商品有在途申请)/批量管理折扣申请(当前商品有在途申请)/优惠申请(当前商品有在途申请)
COMMISSION_SET
(
3
,
"佣金设置"
,
Arrays
.
asList
(
6
,
11
,
14
,
23
,
28
)),
// 拆单申请/合单申请/订单修改/退仓/撤销拆单审批
WEIGHT_DISCOUNT
(
4
,
"重货优惠"
,
Arrays
.
asList
(
6
,
11
,
14
,
22
,
23
,
28
)),
// 拆单申请/合单申请/订单修改/入仓修改/退仓/撤销拆单审批
BUBBLE_DISCOUNT
(
5
,
"泡货优惠"
,
Arrays
.
asList
(
6
,
11
,
14
,
22
,
23
,
28
,
29
)),
// 拆单申请/合单申请/订单修改/入仓修改/退仓/撤销拆单审批/泡重特价优惠
ORDER_SPLIT
(
6
,
"拆单"
,
Collections
.
singletonList
(-
1
)),
// 全部互斥,订单无任何在途审批才可以申请
ORDER_CARGO_CONTROL_PICK_UPDATE
(
7
,
"控货订单放货修改"
,
null
),
// 无限制
ORDER_CARGO_CONTROL_PICK_ANTI_CHECKING
(
8
,
"控货订单反复核"
,
null
),
// 无限制
seasoning_condiments
(
9
,
"调货"
,
null
),
// 无限制
order_cargo_control_cancel_pick
(
10
,
"取消放货"
,
null
),
// 无限制
merge_order
(
11
,
"合单"
,
Collections
.
singletonList
(-
1
)),
// 全部互斥,订单无任何在途审批才可以申请
expense_apply
(
12
,
"费用申请"
,
Arrays
.
asList
(
6
,
11
,
28
)),
// 拆单申请/合单申请/撤销拆单审批
WAREHOUSE_ADJUST
(
13
,
"调仓"
,
Arrays
.
asList
(
6
,
11
,
14
,
22
,
23
,
28
)),
// 拆单申请/合单申请/订单修改/入仓修改/退仓/撤销拆单审批
ORDER_UPDATE
(
14
,
"订单修改"
,
Arrays
.
asList
(
1
,
2
,
3
,
4
,
5
,
6
,
11
,
23
,
28
,
31
,
32
)),
// 拆单申请/合单申请/优惠申请/管理优惠/重货优惠/泡货优惠/退仓/佣金设置
pre_install
(
18
,
"预装审核"
,
Arrays
.
asList
(
6
,
11
,
13
,
14
,
22
,
23
,
28
)),
// 自编号全部申请互斥,跟原本一致,不修改,自编号下订单除拆单申请/合单申请/调仓申请/订单修改/入仓申请/退仓申请外,其他申请不受限制,允许订单预装
closure
(
19
,
"封柜审核"
,
null
),
// 自编号全部申请互斥,跟原本一致,不修改
unloading_cabinet
(
20
,
"卸柜审核"
,
null
),
// 自编号全部申请互斥,跟原本一致,不修改
WAREHOUSE_UPDATE
(
22
,
"入仓修改"
,
Arrays
.
asList
(
6
,
11
,
23
,
28
)),
// 拆单申请/合单申请/退仓
WAREHOUSE_ROLLBACK
(
23
,
"退仓"
,
Collections
.
singletonList
(-
1
)),
// 全部互斥,订单无任何在途审批才可以申请
DISCOUNT_APPLY_BATCH
(
31
,
"批量优惠申请"
),
ADMIN_DISCOUNT_BATCH
(
32
,
"批量管理折扣申请"
),
pre_install_back
(
24
,
"预装反审"
,
null
),
// 自编号全部申请互斥,跟原本一致,不修改, 自编号下订单任何申请不受限制
closure_back
(
25
,
"封柜反审"
,
null
),
// 自编号全部申请互斥,跟原本一致,不修改, 自编号下订单任何申请不受限制
unloading_cabinet_back
(
26
,
"卸柜反审"
,
null
),
// 自编号全部申请互斥,跟原本一致,不修改, 自编号下订单任何申请不受限制
customs_exit
(
27
,
"报关审批"
,
null
),
// 自编号全部申请互斥,跟原本一致,不修改, 自编号下订单任何申请不受限制
ORDER_SPLIT_REVOKE
(
28
,
"撤销订单拆单"
,
Collections
.
singletonList
(-
1
)),
// 全部互斥,订单无任何在途审批才可以申请
BUBBLE_WEIGHT_SPECIAL_DISCOUNT
(
29
,
"泡重特价优惠"
,
Arrays
.
asList
(
5
,
6
,
11
,
14
,
22
,
23
,
28
)),
// 拆单申请/合单申请/订单修改/入仓修改/退仓/撤销拆单审批/泡货优惠
DISCOUNT_APPLY_BATCH
(
31
,
"批量优惠申请"
,
Arrays
.
asList
(
1
,
2
,
6
,
11
,
14
,
23
,
28
,
32
)),
// 拆单申请/合单申请/订单修改/退仓/撤销拆单审批/优惠申请(当前商品有在途申请)/批量管理折扣申请(当前商品有在途申请)/管理优惠(当前商品有在途申请)
ADMIN_DISCOUNT_BATCH
(
32
,
"批量管理折扣申请"
,
Arrays
.
asList
(
1
,
2
,
6
,
11
,
14
,
23
,
28
,
31
)),
// 拆单申请/合单申请/订单修改/退仓/撤销拆单审批/优惠申请(当前商品有在途申请)/批量优惠申请(当前商品有在途申请)/管理优惠(当前商品有在途申请)
//分拣
sorting
(
50
,
"分拣审批"
),
sorting
(
50
,
"分拣审批"
,
Arrays
.
asList
(
6
,
11
,
13
,
14
,
22
,
23
,
28
)),
// 自编号全部申请互斥,跟原本一致,不修改, 自编号下订单除拆单申请/合单申请/调仓申请/订单修改/入仓申请/退仓申请外,其他申请不受限制,允许封柜反审批
//分拣反审
sorting_back
(
51
,
"分拣反审"
),
sorting_back
(
51
,
"分拣反审"
,
null
),
// 自编号全部申请互斥,跟原本一致,不修改,自编号下订单任何申请不受限制
//到仓
warehoused
(
52
,
"到仓审批"
),
warehoused
(
52
,
"到仓审批"
,
null
),
// 自编号全部申请互斥,跟原本一致,不修改,自编号下订单任何申请不受限制
//到仓反审
warehoused_back
(
53
,
"到仓反审"
),
warehoused_back
(
53
,
"到仓反审"
,
null
),
// 自编号全部申请互斥,跟原本一致,不修改,自编号下订单任何申请不受限制
// 出货
shipment
(
54
,
"出货审批"
,
null
),
// 自编号全部申请互斥,跟原本一致,不修改,自编号下订单任何申请不受限制
// 出货反审
shipment_back
(
55
,
"出货反审"
,
null
),
// 自编号全部申请互斥,跟原本一致,不修改,自编号下订单任何申请不受限制
// 撤销清关
clearance_back
(
56
,
"撤销清关"
,
null
),
// 自编号全部申请互斥,跟原本一致,不修改,自编号下订单任何申请不受限制
//收货人限制修改
CONSIGNEE_LIMIT_UPDATE
(
61
,
"收货人限制修改"
),
CONSIGNEE_LIMIT_UPDATE
(
61
,
"收货人限制修改"
,
Arrays
.
asList
(
6
,
11
,
14
,
23
,
28
)),
// 拆单申请/合单申请/订单修改/退仓/撤销拆单审批
//海外仓修改
OVERSEAS_WAREHOUSE_UPDATE
(
62
,
"海外仓修改"
),
OVERSEAS_WAREHOUSE_UPDATE
(
62
,
"海外仓修改"
,
Arrays
.
asList
(
6
,
11
,
14
,
23
,
28
)),
// 拆单申请/合单申请/订单修改/退仓/撤销拆单审批
;
...
...
@@ -65,6 +76,10 @@ public enum OrderApprovalTypeEnum {
* 类型名
*/
private
final
String
name
;
/**
* 互斥审批类型
*/
private
final
List
<
Integer
>
mutualExclusionValues
;
public
static
OrderApprovalTypeEnum
valueOf
(
Integer
value
)
{
return
ArrayUtil
.
firstMatch
(
orderApprovalType
->
orderApprovalType
.
getValue
().
equals
(
value
),
OrderApprovalTypeEnum
.
values
());
...
...
yudao-module-order/yudao-module-order-core/src/main/java/cn/iocoder/yudao/module/order/listener/OrderApprovalTypeCheckListener.java
0 → 100644
View file @
53b1aa90
package
cn
.
iocoder
.
yudao
.
module
.
order
.
listener
;
import
cn.iocoder.yudao.framework.apollo.core.event.Order.OrderApprovalTypeCheckEvent
;
import
cn.iocoder.yudao.module.order.enums.OrderApprovalTypeEnum
;
import
cn.iocoder.yudao.module.order.service.approval.OrderApprovalService
;
import
lombok.AllArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.context.event.EventListener
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
import
java.util.Objects
;
/**
* 校验审批类型是否互斥
*
* @author zhengYi
*/
@Component
(
"MemberRegListener"
)
@AllArgsConstructor
@Slf4j
public
class
OrderApprovalTypeCheckListener
{
private
final
OrderApprovalService
orderApprovalService
;
@EventListener
(
OrderApprovalTypeCheckEvent
.
class
)
public
void
orderApprovalTypeCheckEvent
(
OrderApprovalTypeCheckEvent
event
)
{
OrderApprovalTypeEnum
approvalTypeEnum
=
OrderApprovalTypeEnum
.
valueOf
(
event
.
getApprovalType
());
if
(
Objects
.
isNull
(
approvalTypeEnum
)){
// 没有配置相关审批类型则不做校验
event
.
setResult
(
Boolean
.
FALSE
);
return
;
}
List
<
Integer
>
types
=
approvalTypeEnum
.
getMutualExclusionValues
();
if
(
Objects
.
isNull
(
types
)){
// 没有配置相关审批类型则不做校验
event
.
setResult
(
Boolean
.
FALSE
);
return
;
}
if
(
types
.
contains
(-
1
)){
// 包含负一则表示订单不能有任何审批状态存在
types
=
null
;
}
else
{
types
.
add
(
event
.
getApprovalType
());
}
// 查询当前订单正在进行的审批
// TODO 当订单互斥所有审批类型时,是否也要对自编号的审批状态进行校验
boolean
result
=
orderApprovalService
.
countProcessingApproval
(
event
.
getOrderId
(),
event
.
getOrderItemId
(),
types
);
event
.
setResult
(
result
);
}
}
yudao-module-order/yudao-module-order-core/src/main/java/cn/iocoder/yudao/module/order/service/approval/OrderApprovalService.java
View file @
53b1aa90
...
...
@@ -113,6 +113,15 @@ public interface OrderApprovalService extends IService<OrderApprovalDO> {
OrderApprovalDO
getLast
(
Long
orderId
,
OrderApprovalTypeEnum
orderApprovalTypeEnum
);
/**
* 获取正在处理中的批量审批(批量优惠/批量特价)
* @param orderId 订单id
* @param orderItemId 订单项id
* @param approvalTypes 类型
* @return
*/
boolean
countProcessingApproval
(
Long
orderId
,
Long
orderItemId
,
List
<
Integer
>
approvalTypes
);
/**
* 获取正在处理中的批量审批(批量优惠/批量特价)
* @param orderId
...
...
yudao-module-order/yudao-module-order-core/src/main/java/cn/iocoder/yudao/module/order/service/approval/OrderApprovalServiceImpl.java
View file @
53b1aa90
...
...
@@ -176,6 +176,12 @@ public class OrderApprovalServiceImpl extends AbstractService<OrderApprovalMappe
.
eq
(
OrderApprovalDO:
:
getType
,
orderApprovalTypeEnum
.
getValue
()).
orderByDesc
(
OrderApprovalDO:
:
getOrderApprovalId
).
last
(
"limit 1"
));
}
@Override
public
boolean
countProcessingApproval
(
Long
orderId
,
Long
orderItemId
,
List
<
Integer
>
types
)
{
long
count
=
approvalMapper
.
countProcessingApproval
(
orderId
,
orderItemId
,
types
);
return
count
==
0
;
}
@Override
public
OrderApprovalDO
getProcessingItemBatchApproval
(
Long
orderId
,
Long
orderItemId
)
{
...
...
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