Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c1e137db
authored
Nov 01, 2025
by
李幸鑫
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'new-pay' of git.lijinqi.com:new-computility/api into new-pay
parents
4a90c71d
3dde2664
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
351 additions
and
2 deletions
+351
-2
computility-module-apihub/computility-module-apihub-biz/src/main/java/com/luhu/computility/module/apihub/service/expire/ApiHubOrderExpireServiceImpl.java
+70
-0
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/service/expire/ComputeOrderExpireServiceImpl.java
+70
-0
computility-module-pay/pom.xml
+12
-0
computility-module-pay/src/main/java/com/luhu/computility/module/pay/enums/OrderBusinessTypeEnum.java
+55
-0
computility-module-pay/src/main/java/com/luhu/computility/module/pay/service/expire/BusinessOrderExpireManager.java
+74
-0
computility-module-pay/src/main/java/com/luhu/computility/module/pay/service/expire/BusinessOrderExpireService.java
+28
-0
computility-module-pay/src/main/java/com/luhu/computility/module/pay/service/wpgj/PayOrderWpgjServiceImpl.java
+42
-2
No files found.
computility-module-apihub/computility-module-apihub-biz/src/main/java/com/luhu/computility/module/apihub/service/expire/ApiHubOrderExpireServiceImpl.java
0 → 100644
View file @
c1e137db
package
com
.
luhu
.
computility
.
module
.
apihub
.
service
.
expire
;
import
com.luhu.computility.module.apihub.dal.mysql.apiorder.ApiOrderMapper
;
import
com.luhu.computility.module.apihub.dal.dataobject.apiorder.ApiOrderDO
;
import
com.luhu.computility.module.apihub.enums.ApihubOrderStatusEnum
;
import
com.luhu.computility.module.pay.enums.OrderBusinessTypeEnum
;
import
com.luhu.computility.module.pay.service.expire.BusinessOrderExpireService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
/**
* APIHub订单过期服务实现类
*
* @author jony
*/
@Service
@Slf4j
public
class
ApiHubOrderExpireServiceImpl
implements
BusinessOrderExpireService
{
@Resource
private
ApiOrderMapper
apiOrderMapper
;
@Override
public
OrderBusinessTypeEnum
getSupportedBusinessType
()
{
return
OrderBusinessTypeEnum
.
API_HUB
;
}
@Override
public
boolean
expireBusinessOrder
(
Long
businessOrderId
)
{
try
{
// 查询订单
ApiOrderDO
order
=
apiOrderMapper
.
selectById
(
businessOrderId
);
if
(
order
==
null
)
{
log
.
warn
(
"[expireBusinessOrder] API订单不存在,订单ID: {}"
,
businessOrderId
);
return
false
;
}
// 检查订单状态,只有待支付的订单才能过期
if
(!
ApihubOrderStatusEnum
.
UNPAID
.
getValue
().
equals
(
order
.
getStatus
()))
{
log
.
warn
(
"[expireBusinessOrder] API订单状态不是待支付,无法过期,订单ID: {}, 当前状态: {}"
,
businessOrderId
,
order
.
getStatus
());
return
false
;
}
// 更新订单状态为已取消
ApiOrderDO
updateOrder
=
new
ApiOrderDO
();
updateOrder
.
setId
(
businessOrderId
);
updateOrder
.
setStatus
(
ApihubOrderStatusEnum
.
CANCELED
.
getValue
());
updateOrder
.
setCancelTime
(
LocalDateTime
.
now
());
int
updateCount
=
apiOrderMapper
.
updateById
(
updateOrder
);
if
(
updateCount
>
0
)
{
log
.
info
(
"[expireBusinessOrder] API订单过期成功,订单ID: {}"
,
businessOrderId
);
return
true
;
}
else
{
log
.
error
(
"[expireBusinessOrder] API订单过期失败,更新数据库失败,订单ID: {}"
,
businessOrderId
);
return
false
;
}
}
catch
(
Exception
e
)
{
log
.
error
(
"[expireBusinessOrder] 过期API订单异常,订单ID: {}"
,
businessOrderId
,
e
);
return
false
;
}
}
}
\ No newline at end of file
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/service/expire/ComputeOrderExpireServiceImpl.java
0 → 100644
View file @
c1e137db
package
com
.
luhu
.
computility
.
module
.
compute
.
service
.
expire
;
import
com.luhu.computility.module.compute.dal.mysql.resourceorder.ResourceOrderMapper
;
import
com.luhu.computility.module.compute.dal.dataobject.resourceorder.ResourceOrderDO
;
import
com.luhu.computility.module.compute.enums.ResourceOrderStatus
;
import
com.luhu.computility.module.pay.enums.OrderBusinessTypeEnum
;
import
com.luhu.computility.module.pay.service.expire.BusinessOrderExpireService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
/**
* 算力资源订单过期服务实现类
*
* @author jony
*/
@Service
@Slf4j
public
class
ComputeOrderExpireServiceImpl
implements
BusinessOrderExpireService
{
@Resource
private
ResourceOrderMapper
resourceOrderMapper
;
@Override
public
OrderBusinessTypeEnum
getSupportedBusinessType
()
{
return
OrderBusinessTypeEnum
.
COMPUTE_RESOURCE
;
}
@Override
public
boolean
expireBusinessOrder
(
Long
businessOrderId
)
{
try
{
// 查询订单
ResourceOrderDO
order
=
resourceOrderMapper
.
selectById
(
businessOrderId
);
if
(
order
==
null
)
{
log
.
warn
(
"[expireBusinessOrder] 算力资源订单不存在,订单ID: {}"
,
businessOrderId
);
return
false
;
}
// 检查订单状态,只有待支付的订单才能过期
if
(!
ResourceOrderStatus
.
UNPAID
.
getValue
().
equals
(
order
.
getStatus
()))
{
log
.
warn
(
"[expireBusinessOrder] 算力资源订单状态不是待支付,无法过期,订单ID: {}, 当前状态: {}"
,
businessOrderId
,
order
.
getStatus
());
return
false
;
}
// 更新订单状态为已取消
ResourceOrderDO
updateOrder
=
new
ResourceOrderDO
();
updateOrder
.
setId
(
businessOrderId
);
updateOrder
.
setStatus
(
ResourceOrderStatus
.
CANCELED
.
getValue
());
updateOrder
.
setCancelTime
(
LocalDateTime
.
now
());
int
updateCount
=
resourceOrderMapper
.
updateById
(
updateOrder
);
if
(
updateCount
>
0
)
{
log
.
info
(
"[expireBusinessOrder] 算力资源订单过期成功,订单ID: {}"
,
businessOrderId
);
return
true
;
}
else
{
log
.
error
(
"[expireBusinessOrder] 算力资源订单过期失败,更新数据库失败,订单ID: {}"
,
businessOrderId
);
return
false
;
}
}
catch
(
Exception
e
)
{
log
.
error
(
"[expireBusinessOrder] 过期算力资源订单异常,订单ID: {}"
,
businessOrderId
,
e
);
return
false
;
}
}
}
\ No newline at end of file
computility-module-pay/pom.xml
View file @
c1e137db
...
@@ -31,6 +31,18 @@
...
@@ -31,6 +31,18 @@
<artifactId>
computility-spring-boot-starter-biz-tenant
</artifactId>
<artifactId>
computility-spring-boot-starter-biz-tenant
</artifactId>
</dependency>
</dependency>
<!-- 业务模块API依赖 -->
<dependency>
<groupId>
com.luhu
</groupId>
<artifactId>
computility-module-compute-api
</artifactId>
<version>
${revision}
</version>
</dependency>
<dependency>
<groupId>
com.luhu
</groupId>
<artifactId>
computility-module-apihub-api
</artifactId>
<version>
${revision}
</version>
</dependency>
<!-- Web 相关 -->
<!-- Web 相关 -->
<dependency>
<dependency>
<groupId>
com.luhu
</groupId>
<groupId>
com.luhu
</groupId>
...
...
computility-module-pay/src/main/java/com/luhu/computility/module/pay/enums/OrderBusinessTypeEnum.java
0 → 100644
View file @
c1e137db
package
com
.
luhu
.
computility
.
module
.
pay
.
enums
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
/**
* 订单业务类型枚举
*
* @author jony
*/
@Getter
@AllArgsConstructor
public
enum
OrderBusinessTypeEnum
{
COMPUTE_RESOURCE
(
1
,
"算力资源订单"
),
API_HUB
(
2
,
"API订单"
);
private
final
Integer
value
;
private
final
String
name
;
/**
* 根据值获取枚举
*/
public
static
OrderBusinessTypeEnum
fromValue
(
Integer
value
)
{
for
(
OrderBusinessTypeEnum
type
:
values
())
{
if
(
type
.
getValue
().
equals
(
value
))
{
return
type
;
}
}
return
null
;
}
/**
* 根据值获取名称
*/
public
static
String
getNameByValue
(
Integer
value
)
{
OrderBusinessTypeEnum
typeEnum
=
fromValue
(
value
);
return
typeEnum
!=
null
?
typeEnum
.
getName
()
:
null
;
}
/**
* 判断是否是算力资源订单
*/
public
static
boolean
isComputeResource
(
Integer
businessType
)
{
return
COMPUTE_RESOURCE
.
getValue
().
equals
(
businessType
);
}
/**
* 判断是否是API订单
*/
public
static
boolean
isApiHub
(
Integer
businessType
)
{
return
API_HUB
.
getValue
().
equals
(
businessType
);
}
}
computility-module-pay/src/main/java/com/luhu/computility/module/pay/service/expire/BusinessOrderExpireManager.java
0 → 100644
View file @
c1e137db
package
com
.
luhu
.
computility
.
module
.
pay
.
service
.
expire
;
import
com.luhu.computility.module.pay.enums.OrderBusinessTypeEnum
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.PostConstruct
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* 业务订单过期管理器
*
* @author jony
*/
@Service
@Slf4j
public
class
BusinessOrderExpireManager
{
@Autowired
private
ApplicationContext
applicationContext
;
private
Map
<
Integer
,
BusinessOrderExpireService
>
expireServiceMap
=
new
HashMap
<>();
@PostConstruct
public
void
init
()
{
// 获取所有BusinessOrderExpireService的实现
Map
<
String
,
BusinessOrderExpireService
>
services
=
applicationContext
.
getBeansOfType
(
BusinessOrderExpireService
.
class
);
for
(
BusinessOrderExpireService
service
:
services
.
values
())
{
OrderBusinessTypeEnum
supportedType
=
service
.
getSupportedBusinessType
();
if
(
supportedType
!=
null
)
{
expireServiceMap
.
put
(
supportedType
.
getValue
(),
service
);
log
.
info
(
"[init] 注册业务订单过期服务: {} -> {}"
,
supportedType
.
getName
(),
service
.
getClass
().
getSimpleName
());
}
}
log
.
info
(
"[init] 业务订单过期服务注册完成,共注册 {} 个服务"
,
expireServiceMap
.
size
());
}
/**
* 根据业务类型过期业务订单
*
* @param businessType 业务类型
* @param businessOrderId 业务订单ID
* @return 是否过期成功
*/
public
boolean
expireBusinessOrder
(
Integer
businessType
,
Long
businessOrderId
)
{
BusinessOrderExpireService
service
=
expireServiceMap
.
get
(
businessType
);
if
(
service
==
null
)
{
log
.
error
(
"[expireBusinessOrder] 未找到业务类型 {} 对应的过期服务"
,
businessType
);
return
false
;
}
try
{
log
.
info
(
"[expireBusinessOrder] 开始过期业务订单,业务类型: {}, 订单ID: {}"
,
businessType
,
businessOrderId
);
boolean
success
=
service
.
expireBusinessOrder
(
businessOrderId
);
if
(
success
)
{
log
.
info
(
"[expireBusinessOrder] 业务订单过期成功,业务类型: {}, 订单ID: {}"
,
businessType
,
businessOrderId
);
}
else
{
log
.
error
(
"[expireBusinessOrder] 业务订单过期失败,业务类型: {}, 订单ID: {}"
,
businessType
,
businessOrderId
);
}
return
success
;
}
catch
(
Exception
e
)
{
log
.
error
(
"[expireBusinessOrder] 过期业务订单异常,业务类型: {}, 订单ID: {}"
,
businessType
,
businessOrderId
,
e
);
return
false
;
}
}
}
\ No newline at end of file
computility-module-pay/src/main/java/com/luhu/computility/module/pay/service/expire/BusinessOrderExpireService.java
0 → 100644
View file @
c1e137db
package
com
.
luhu
.
computility
.
module
.
pay
.
service
.
expire
;
import
com.luhu.computility.module.pay.enums.OrderBusinessTypeEnum
;
/**
* 业务订单过期服务接口
*
* @author jony
*/
public
interface
BusinessOrderExpireService
{
/**
* 获取支持的业务类型
*
* @return 业务类型
*/
OrderBusinessTypeEnum
getSupportedBusinessType
();
/**
* 过期业务订单
*
* @param businessOrderId 业务订单ID
* @return 是否过期成功
*/
boolean
expireBusinessOrder
(
Long
businessOrderId
);
}
\ No newline at end of file
computility-module-pay/src/main/java/com/luhu/computility/module/pay/service/wpgj/PayOrderWpgjServiceImpl.java
View file @
c1e137db
...
@@ -8,6 +8,7 @@ import com.luhu.computility.module.pay.dal.dataobject.wpgj.PayOrderWpgjDO;
...
@@ -8,6 +8,7 @@ import com.luhu.computility.module.pay.dal.dataobject.wpgj.PayOrderWpgjDO;
import
com.luhu.computility.module.pay.dal.mysql.wpgj.PayOrderWpgjMapper
;
import
com.luhu.computility.module.pay.dal.mysql.wpgj.PayOrderWpgjMapper
;
import
com.luhu.computility.module.pay.enums.WpgjOrderStatusEnum
;
import
com.luhu.computility.module.pay.enums.WpgjOrderStatusEnum
;
import
com.luhu.computility.module.pay.framework.pay.core.client.impl.wpgj.WpgjPayProperties
;
import
com.luhu.computility.module.pay.framework.pay.core.client.impl.wpgj.WpgjPayProperties
;
import
com.luhu.computility.module.pay.service.expire.BusinessOrderExpireManager
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
...
@@ -33,6 +34,9 @@ public class PayOrderWpgjServiceImpl implements PayOrderWpgjService {
...
@@ -33,6 +34,9 @@ public class PayOrderWpgjServiceImpl implements PayOrderWpgjService {
@Resource
@Resource
private
WpgjPayProperties
wpgjPayProperties
;
private
WpgjPayProperties
wpgjPayProperties
;
@Resource
private
BusinessOrderExpireManager
businessOrderExpireManager
;
@Override
@Override
public
Long
saveOrder
(
WpgjPayNotifyDTO
notifyDTO
)
{
public
Long
saveOrder
(
WpgjPayNotifyDTO
notifyDTO
)
{
// 查询是否已存在相同商户订单ID的记录
// 查询是否已存在相同商户订单ID的记录
...
@@ -91,10 +95,14 @@ public class PayOrderWpgjServiceImpl implements PayOrderWpgjService {
...
@@ -91,10 +95,14 @@ public class PayOrderWpgjServiceImpl implements PayOrderWpgjService {
return
0
;
return
0
;
}
}
// 2. 遍历执行,将过期的待支付订单标记为已取消
// 2. 遍历执行,将过期的待支付订单标记为已取消
,并同时过期对应的业务订单
int
count
=
0
;
int
count
=
0
;
for
(
PayOrderWpgjDO
order
:
orders
)
{
for
(
PayOrderWpgjDO
order
:
orders
)
{
count
+=
expireOrder
(
order
)
?
1
:
0
;
if
(
expireOrder
(
order
))
{
count
++;
// 同时过期对应的业务订单
expireBusinessOrder
(
order
);
}
}
}
return
count
;
return
count
;
}
}
...
@@ -126,4 +134,35 @@ public class PayOrderWpgjServiceImpl implements PayOrderWpgjService {
...
@@ -126,4 +134,35 @@ public class PayOrderWpgjServiceImpl implements PayOrderWpgjService {
}
}
}
}
/**
* 过期业务订单
*
* @param payOrder WPGJ支付订单
*/
private
void
expireBusinessOrder
(
PayOrderWpgjDO
payOrder
)
{
try
{
Integer
businessType
=
payOrder
.
getBusinessType
();
String
merOrderId
=
payOrder
.
getMerOrderId
();
if
(
businessType
==
null
||
merOrderId
==
null
)
{
log
.
warn
(
"[expireBusinessOrder] 业务类型或商户订单ID为空,无法过期业务订单,WPGJ订单ID: {}"
,
payOrder
.
getOrderId
());
return
;
}
// 调用业务订单过期管理器过期业务订单
boolean
success
=
businessOrderExpireManager
.
expireBusinessOrder
(
businessType
,
Long
.
valueOf
(
merOrderId
));
if
(
success
)
{
log
.
info
(
"[expireBusinessOrder] 业务订单过期成功,业务类型: {}, 订单ID: {}, WPGJ订单ID: {}"
,
businessType
,
merOrderId
,
payOrder
.
getOrderId
());
}
else
{
log
.
error
(
"[expireBusinessOrder] 业务订单过期失败,业务类型: {}, 订单ID: {}, WPGJ订单ID: {}"
,
businessType
,
merOrderId
,
payOrder
.
getOrderId
());
}
}
catch
(
Exception
e
)
{
log
.
error
(
"[expireBusinessOrder] 过期业务订单异常,WPGJ订单ID: {}"
,
payOrder
.
getOrderId
(),
e
);
}
}
}
}
\ No newline at end of file
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