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
95512b4d
authored
Oct 19, 2025
by
Jony.L
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
算力资源重构-收尾修改 支付、发票、字段修改等
parent
8e81bfe5
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
575 additions
and
90 deletions
+575
-90
computility-module-compute/computility-module-compute-api/src/main/java/com/luhu/computility/module/compute/enums/ResourceOrderInvoiceStatus.java
+41
-0
computility-module-compute/computility-module-compute-api/src/main/java/com/luhu/computility/module/compute/enums/ResourceOrderRefundStatus.java
+41
-0
computility-module-compute/computility-module-compute-biz/pom.xml
+7
-0
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/config/ResourceOrderConfig.java
+16
-0
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/config/ResourceOrderProperties.java
+38
-0
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/controller/admin/resourceorder/ResourceOrderController.java
+62
-25
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/controller/admin/resourceorder/vo/ResourceOrderRespVO.java
+4
-0
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/controller/app/resourceorder/AppResourceOrderController.java
+9
-0
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/controller/app/resourceorder/ResourceOrderPayController.java
+0
-38
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/controller/app/resourceorder/vo/AppResourceOrderInvoiceReqVO.java
+18
-0
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/controller/app/resourceorder/vo/AppResourceOrderPageReqVO.java
+44
-0
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/controller/app/resourceorder/vo/AppResourceOrderRespVO.java
+84
-0
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/dal/mysql/resourceorder/ResourceOrderMapper.java
+31
-1
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/dal/redis/RedisKeyConstants.java
+19
-0
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/dal/redis/no/ResourceOrderNoRedisDAO.java
+41
-0
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/service/resourceorder/ResourceOrderService.java
+19
-1
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/service/resourceorder/ResourceOrderServiceImpl.java
+97
-20
computility-module-mall/computility-module-trade/src/main/java/com/luhu/computility/module/trade/controller/app/order/AppTradeOrderController.java
+1
-5
computility-module-mall/computility-module-trade/src/main/java/com/luhu/computility/module/trade/service/order/TradeOrderUpdateServiceImpl.java
+3
-0
No files found.
computility-module-compute/computility-module-compute-api/src/main/java/com/luhu/computility/module/compute/enums/ResourceOrderInvoiceStatus.java
0 → 100644
View file @
95512b4d
package
com
.
luhu
.
computility
.
module
.
compute
.
enums
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
/**
* 算力资源订单发票状态枚举
*
* @Author: jony
* @Date : 2025/10/11
* @VERSION v1.0
*/
@AllArgsConstructor
@Getter
public
enum
ResourceOrderInvoiceStatus
{
UNINVOICE
(
0
,
"未开票"
),
INVOICING
(
1
,
"开票中"
),
INVOICED
(
2
,
"已开票"
);
private
final
Integer
value
;
private
final
String
label
;
public
static
ResourceOrderInvoiceStatus
getByValue
(
int
value
)
{
for
(
ResourceOrderInvoiceStatus
status
:
ResourceOrderInvoiceStatus
.
values
())
{
if
(
status
.
getValue
()
==
value
)
{
return
status
;
}
}
return
null
;
}
public
static
String
getLabelByValue
(
Integer
value
)
{
for
(
ResourceOrderInvoiceStatus
status
:
values
())
{
if
(
status
.
getValue
()
==
value
)
{
return
status
.
getLabel
();
}
}
return
null
;
}
}
\ No newline at end of file
computility-module-compute/computility-module-compute-api/src/main/java/com/luhu/computility/module/compute/enums/ResourceOrderRefundStatus.java
0 → 100644
View file @
95512b4d
package
com
.
luhu
.
computility
.
module
.
compute
.
enums
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
/**
* 算力资源订单退款状态枚举
*
* @Author: jony
* @Date : 2025/10/11
* @VERSION v1.0
*/
@AllArgsConstructor
@Getter
public
enum
ResourceOrderRefundStatus
{
NOT_REFUND
(
0
,
"未退款"
),
REFUNDING
(
1
,
"退款中"
),
REFUNDED
(
2
,
"已退款"
);
private
final
Integer
value
;
private
final
String
label
;
public
static
ResourceOrderRefundStatus
getByValue
(
int
value
)
{
for
(
ResourceOrderRefundStatus
status
:
ResourceOrderRefundStatus
.
values
())
{
if
(
status
.
getValue
()
==
value
)
{
return
status
;
}
}
return
null
;
}
public
static
String
getLabelByValue
(
Integer
value
)
{
for
(
ResourceOrderRefundStatus
status
:
values
())
{
if
(
status
.
getValue
()
==
value
)
{
return
status
.
getLabel
();
}
}
return
null
;
}
}
\ No newline at end of file
computility-module-compute/computility-module-compute-biz/pom.xml
View file @
95512b4d
...
@@ -88,6 +88,12 @@
...
@@ -88,6 +88,12 @@
<groupId>
com.luhu
</groupId>
<groupId>
com.luhu
</groupId>
<artifactId>
computility-spring-boot-starter-excel
</artifactId>
<artifactId>
computility-spring-boot-starter-excel
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
com.luhu
</groupId>
<artifactId>
computility-module-member
</artifactId>
<version>
2.6.0-jdk8-SNAPSHOT
</version>
<scope>
compile
</scope>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
\ No newline at end of file
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/config/ResourceOrderConfig.java
0 → 100644
View file @
95512b4d
package
com
.
luhu
.
computility
.
module
.
compute
.
config
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.context.annotation.Configuration
;
/**
* 算力资源订单配置
*
* @author jony
* @since 2025-10-13
*/
@Configuration
@EnableConfigurationProperties
(
ResourceOrderProperties
.
class
)
public
class
ResourceOrderConfig
{
}
\ No newline at end of file
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/config/ResourceOrderProperties.java
0 → 100644
View file @
95512b4d
package
com
.
luhu
.
computility
.
module
.
compute
.
config
;
import
lombok.Data
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.validation.annotation.Validated
;
import
javax.validation.constraints.NotEmpty
;
import
javax.validation.constraints.NotNull
;
import
java.time.Duration
;
/**
* 算力资源订单的配置项
*
* @author jony
*/
@ConfigurationProperties
(
prefix
=
"computility.compute.order"
)
@Data
@Validated
public
class
ResourceOrderProperties
{
private
static
final
String
PAY_APP_KEY_DEFAULT
=
"computemall"
;
/**
* 支付应用标识
*
* 在 pay 模块的 [支付管理 -> 应用信息]
*/
@NotEmpty
(
message
=
"Pay 应用标识不能为空"
)
private
String
payAppKey
=
PAY_APP_KEY_DEFAULT
;
/**
* 支付超时时间
*/
@NotNull
(
message
=
"支付超时时间不能为空"
)
private
Duration
payExpireTime
;
}
\ No newline at end of file
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/controller/admin/resourceorder/ResourceOrderController.java
View file @
95512b4d
package
com
.
luhu
.
computility
.
module
.
compute
.
controller
.
admin
.
resourceorder
;
package
com
.
luhu
.
computility
.
module
.
compute
.
controller
.
admin
.
resourceorder
;
import
org.springframework.web.bind.annotation.*
;
import
cn.hutool.core.util.ObjectUtil
;
import
javax.annotation.Resource
;
import
com.luhu.computility.framework.common.exception.ServiceException
;
import
org.springframework.validation.annotation.Validated
;
import
com.luhu.computility.framework.common.pojo.CommonResult
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
com.luhu.computility.framework.common.pojo.PageResult
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
com.luhu.computility.module.compute.controller.admin.resourceorder.vo.*
;
import
com.luhu.computility.module.compute.enums.ResourceOrderInvoiceStatus
;
import
com.luhu.computility.module.compute.enums.ResourceOrderStatus
;
import
io.swagger.v3.oas.annotations.Parameter
;
import
io.swagger.v3.oas.annotations.Parameter
;
import
io.swagger.v3.oas.annotations.Operation
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.validation.constraints.*
;
import
javax.validation.*
;
import
javax.servlet.http.*
;
import
java.util.*
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.List
;
import
com.luhu.computility.framework.common.pojo.PageParam
;
import
com.luhu.computility.framework.common.pojo.PageResult
;
import
com.luhu.computility.framework.common.pojo.CommonResult
;
import
com.luhu.computility.framework.common.util.object.BeanUtils
;
import
static
com
.
luhu
.
computility
.
framework
.
common
.
pojo
.
CommonResult
.
success
;
import
com.luhu.computility.framework.excel.core.util.ExcelUtils
;
import
com.luhu.computility.framework.excel.core.util.ExcelUtils
;
import
com.luhu.computility.framework.apilog.core.annotation.ApiAccessLog
;
import
com.luhu.computility.framework.apilog.core.annotation.ApiAccessLog
;
import
static
com
.
luhu
.
computility
.
framework
.
apilog
.
core
.
enums
.
OperateTypeEnum
.*;
import
static
com
.
luhu
.
computility
.
framework
.
apilog
.
core
.
enums
.
OperateTypeEnum
.*;
import
com.luhu.computility.framework.common.pojo.PageParam
;
import
com.luhu.computility.module.compute.controller.admin.resourceorder.vo.*
;
import
com.luhu.computility.module.compute.dal.dataobject.resourceorder.ResourceOrderDO
;
import
com.luhu.computility.module.compute.service.resourceorder.ResourceOrderService
;
import
com.luhu.computility.module.compute.service.resourceorder.ResourceOrderService
;
import
com.luhu.computility.module.compute.dal.dataobject.resourceorder.ResourceOrderDO
;
import
com.luhu.computility.module.pay.api.notify.dto.PayOrderNotifyReqDTO
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
javax.annotation.security.PermitAll
;
import
javax.validation.Valid
;
import
org.springframework.validation.annotation.Validated
;
import
static
com
.
luhu
.
computility
.
framework
.
common
.
pojo
.
CommonResult
.
success
;
import
com.luhu.computility.framework.common.util.object.BeanUtils
;
@Tag
(
name
=
"管理后台 - 算力资源订单"
)
@Tag
(
name
=
"管理后台 - 算力资源订单"
)
@RestController
@RestController
@RequestMapping
(
"/compute/resource-order"
)
@RequestMapping
(
"/compute/resource-order"
)
@Validated
@Validated
@Slf4j
public
class
ResourceOrderController
{
public
class
ResourceOrderController
{
@Resource
@Resource
private
ResourceOrderService
resourceOrderService
;
private
ResourceOrderService
resourceOrderService
;
/**
* 内部支付任务回调
*/
@PostMapping
(
"/pay/update-paid"
)
@PermitAll
@Operation
(
summary
=
"支付订单回调,更新订单为已支付"
)
public
CommonResult
<
Boolean
>
updateOrderPaid
(
@Valid
@RequestBody
PayOrderNotifyReqDTO
notifyReqDTO
)
{
log
.
info
(
"[updateOrderPaid][req({})]"
,
notifyReqDTO
);
resourceOrderService
.
updateOrderPaid
(
Long
.
valueOf
(
notifyReqDTO
.
getMerchantOrderId
()),
notifyReqDTO
.
getPayOrderId
());
return
success
(
true
);
}
@PostMapping
(
"/create"
)
@PostMapping
(
"/create"
)
@Operation
(
summary
=
"创建算力资源订单"
)
@Operation
(
summary
=
"创建算力资源订单"
)
@PreAuthorize
(
"@ss.hasPermission('compute:resource-order:create')"
)
@PreAuthorize
(
"@ss.hasPermission('compute:resource-order:create')"
)
...
@@ -84,8 +101,7 @@ public class ResourceOrderController {
...
@@ -84,8 +101,7 @@ public class ResourceOrderController {
@Operation
(
summary
=
"获得算力资源订单分页"
)
@Operation
(
summary
=
"获得算力资源订单分页"
)
@PreAuthorize
(
"@ss.hasPermission('compute:resource-order:query')"
)
@PreAuthorize
(
"@ss.hasPermission('compute:resource-order:query')"
)
public
CommonResult
<
PageResult
<
ResourceOrderRespVO
>>
getResourceOrderPage
(
@Valid
ResourceOrderPageReqVO
pageReqVO
)
{
public
CommonResult
<
PageResult
<
ResourceOrderRespVO
>>
getResourceOrderPage
(
@Valid
ResourceOrderPageReqVO
pageReqVO
)
{
PageResult
<
ResourceOrderDO
>
pageResult
=
resourceOrderService
.
getResourceOrderPage
(
pageReqVO
);
return
success
(
resourceOrderService
.
getResourceOrderPage
(
pageReqVO
));
return
success
(
BeanUtils
.
toBean
(
pageResult
,
ResourceOrderRespVO
.
class
));
}
}
@GetMapping
(
"/export-excel"
)
@GetMapping
(
"/export-excel"
)
...
@@ -95,10 +111,30 @@ public class ResourceOrderController {
...
@@ -95,10 +111,30 @@ public class ResourceOrderController {
public
void
exportResourceOrderExcel
(
@Valid
ResourceOrderPageReqVO
pageReqVO
,
public
void
exportResourceOrderExcel
(
@Valid
ResourceOrderPageReqVO
pageReqVO
,
HttpServletResponse
response
)
throws
IOException
{
HttpServletResponse
response
)
throws
IOException
{
pageReqVO
.
setPageSize
(
PageParam
.
PAGE_SIZE_NONE
);
pageReqVO
.
setPageSize
(
PageParam
.
PAGE_SIZE_NONE
);
List
<
ResourceOrderDO
>
list
=
resourceOrderService
.
getResourceOrderPage
(
pageReqVO
).
getList
();
// 导出 Excel
// 导出 Excel
ExcelUtils
.
write
(
response
,
"算力资源订单.xls"
,
"数据"
,
ResourceOrderRespVO
.
class
,
ExcelUtils
.
write
(
response
,
"算力资源订单.xls"
,
"数据"
,
ResourceOrderRespVO
.
class
,
BeanUtils
.
toBean
(
list
,
ResourceOrderRespVO
.
class
));
resourceOrderService
.
getResourceOrderPage
(
pageReqVO
).
getList
());
}
@PutMapping
(
"/issue-invoice"
)
@Operation
(
summary
=
"开具发票"
)
public
CommonResult
<
Boolean
>
issueInvoice
(
@RequestBody
ResourceOrderSaveReqVO
saveVO
){
if
(
ObjectUtil
.
isEmpty
(
saveVO
.
getInvoiceUrl
())){
throw
new
ServiceException
(
"没有接收到发票文件地址!"
);
}
}
if
(
saveVO
.
getInvoiceStatus
().
equals
(
ResourceOrderInvoiceStatus
.
INVOICED
.
getValue
())){
throw
new
ServiceException
(
"该订单已经开具发票"
);
}
// 校验订单支付状态
ResourceOrderDO
order
=
resourceOrderService
.
getResourceOrder
(
saveVO
.
getId
());
if
(
order
==
null
){
throw
new
ServiceException
(
"订单不存在!"
);
}
if
(!
order
.
getStatus
().
equals
(
ResourceOrderStatus
.
PAID
.
getValue
())){
throw
new
ServiceException
(
"只有已支付的订单可以开票!"
);
}
return
success
(
resourceOrderService
.
updateInvoice
(
saveVO
));
}
}
}
\ No newline at end of file
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/controller/admin/resourceorder/vo/ResourceOrderRespVO.java
View file @
95512b4d
...
@@ -20,6 +20,10 @@ public class ResourceOrderRespVO {
...
@@ -20,6 +20,10 @@ public class ResourceOrderRespVO {
@ExcelProperty
(
"下单用户ID"
)
@ExcelProperty
(
"下单用户ID"
)
private
Long
userId
;
private
Long
userId
;
@Schema
(
description
=
"用户昵称"
,
example
=
"张三"
)
@ExcelProperty
(
"用户昵称"
)
private
String
nickname
;
@Schema
(
description
=
"算力资源SKU ID"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"31061"
)
@Schema
(
description
=
"算力资源SKU ID"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"31061"
)
@ExcelProperty
(
"算力资源SKU ID"
)
@ExcelProperty
(
"算力资源SKU ID"
)
private
Long
skuId
;
private
Long
skuId
;
...
...
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/controller/app/resourceorder/AppResourceOrderController.java
View file @
95512b4d
...
@@ -6,6 +6,7 @@ import com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppRe
...
@@ -6,6 +6,7 @@ import com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppRe
import
com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppResourceOrderCreateRespVO
;
import
com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppResourceOrderCreateRespVO
;
import
com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppResourceOrderPageReqVO
;
import
com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppResourceOrderPageReqVO
;
import
com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppResourceOrderRespVO
;
import
com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppResourceOrderRespVO
;
import
com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppResourceOrderInvoiceReqVO
;
import
com.luhu.computility.module.compute.service.resourceorder.ResourceOrderService
;
import
com.luhu.computility.module.compute.service.resourceorder.ResourceOrderService
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.Parameter
;
import
io.swagger.v3.oas.annotations.Parameter
;
...
@@ -64,4 +65,11 @@ public class AppResourceOrderController {
...
@@ -64,4 +65,11 @@ public class AppResourceOrderController {
return
success
(
orderDetail
);
return
success
(
orderDetail
);
}
}
@PostMapping
(
"/invoice-request"
)
@Operation
(
summary
=
"申请开票"
)
public
CommonResult
<
Boolean
>
invoiceRequest
(
@RequestBody
AppResourceOrderInvoiceReqVO
reqVO
)
{
resourceOrderService
.
updateRequestInvoice
(
reqVO
);
return
success
(
true
);
}
}
}
\ No newline at end of file
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/controller/app/resourceorder/ResourceOrderPayController.java
deleted
100644 → 0
View file @
8e81bfe5
package
com
.
luhu
.
computility
.
module
.
compute
.
controller
.
app
.
resourceorder
;
import
com.luhu.computility.framework.common.pojo.CommonResult
;
import
com.luhu.computility.module.compute.service.resourceorder.ResourceOrderService
;
import
com.luhu.computility.module.pay.api.notify.dto.PayOrderNotifyReqDTO
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
javax.annotation.security.PermitAll
;
import
javax.validation.Valid
;
import
org.springframework.validation.annotation.Validated
;
import
static
com
.
luhu
.
computility
.
framework
.
common
.
pojo
.
CommonResult
.
success
;
@Tag
(
name
=
"支付回调 - 算力资源订单"
)
@RestController
@RequestMapping
(
"/compute/order/pay"
)
@Validated
@Slf4j
public
class
ResourceOrderPayController
{
@Resource
private
ResourceOrderService
resourceOrderService
;
@PostMapping
(
"/update-paid"
)
@Operation
(
summary
=
"支付订单回调,更新订单为已支付"
)
@PermitAll
public
CommonResult
<
Boolean
>
updateOrderPaid
(
@Valid
@RequestBody
PayOrderNotifyReqDTO
notifyReqDTO
)
{
log
.
info
(
"[updateOrderPaid][req({})]"
,
notifyReqDTO
);
resourceOrderService
.
updateOrderPaid
(
Long
.
valueOf
(
notifyReqDTO
.
getMerchantOrderId
()),
notifyReqDTO
.
getPayOrderId
());
return
success
(
true
);
}
}
\ No newline at end of file
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/controller/app/resourceorder/vo/AppResourceOrderInvoiceReqVO.java
0 → 100644
View file @
95512b4d
package
com
.
luhu
.
computility
.
module
.
compute
.
controller
.
app
.
resourceorder
.
vo
;
import
lombok.Data
;
/**
* 用户 App - 算力资源订单申请开票 Request VO
*
* @author jony
*/
@Data
public
class
AppResourceOrderInvoiceReqVO
{
private
Long
id
;
//发票图片链接
private
String
invoiceUrl
;
//开票状态
private
Integer
invoiceStatus
;
}
\ No newline at end of file
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/controller/app/resourceorder/vo/AppResourceOrderPageReqVO.java
0 → 100644
View file @
95512b4d
package
com
.
luhu
.
computility
.
module
.
compute
.
controller
.
app
.
resourceorder
.
vo
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
java.time.LocalDateTime
;
import
static
com
.
luhu
.
computility
.
framework
.
common
.
util
.
date
.
DateUtils
.
FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND
;
@Schema
(
description
=
"用户 APP - 算力资源订单分页 Request VO"
)
@Data
public
class
AppResourceOrderPageReqVO
{
@Schema
(
description
=
"用户编号"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"1024"
)
private
Long
userId
;
@Schema
(
description
=
"订单编号"
,
example
=
"1024"
)
private
Long
id
;
@Schema
(
description
=
"订单号"
,
example
=
"X202410110001"
)
private
String
no
;
@Schema
(
description
=
"分类编号"
,
example
=
"1"
)
private
Long
categoryId
;
@Schema
(
description
=
"订单状态"
,
example
=
"0"
)
private
Integer
status
;
@Schema
(
description
=
"支付订单编号"
,
example
=
"1024"
)
private
Long
payOrderId
;
@Schema
(
description
=
"创建时间"
)
@DateTimeFormat
(
pattern
=
FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND
)
private
LocalDateTime
[]
createTime
;
@Schema
(
description
=
"页码"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"1"
)
private
Integer
pageNo
=
1
;
@Schema
(
description
=
"每页大小"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"10"
)
private
Integer
pageSize
=
10
;
}
\ No newline at end of file
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/controller/app/resourceorder/vo/AppResourceOrderRespVO.java
0 → 100644
View file @
95512b4d
package
com
.
luhu
.
computility
.
module
.
compute
.
controller
.
app
.
resourceorder
.
vo
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
import
java.time.LocalDateTime
;
@Schema
(
description
=
"用户 APP - 算力资源订单 Response VO"
)
@Data
public
class
AppResourceOrderRespVO
{
@Schema
(
description
=
"订单编号"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"1024"
)
private
Long
id
;
@Schema
(
description
=
"订单号"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"X202410110001"
)
private
String
orderNo
;
@Schema
(
description
=
"用户编号"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"1024"
)
private
Long
userId
;
@Schema
(
description
=
"商品SPU编号"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"1"
)
private
Long
spuId
;
@Schema
(
description
=
"商品SPU名称"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"GPU服务器A型"
)
private
String
spuName
;
@Schema
(
description
=
"商品SKU编号"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"1"
)
private
Long
skuId
;
@Schema
(
description
=
"商品SKU名称"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"GPU服务器A型-7天"
)
private
String
skuName
;
@Schema
(
description
=
"分类编号"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"1"
)
private
Long
categoryId
;
@Schema
(
description
=
"分类名称"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"GPU服务器"
)
private
String
categoryName
;
@Schema
(
description
=
"支付价格,单位:分"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"888800"
)
private
Integer
payPrice
;
@Schema
(
description
=
"支付订单编号"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"1024"
)
private
Long
payOrderId
;
@Schema
(
description
=
"订单状态"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"0"
)
private
Integer
status
;
@Schema
(
description
=
"开票状态"
,
example
=
"0"
)
private
Integer
invoiceStatus
;
@Schema
(
description
=
"发票文件URL"
,
example
=
"https://example.com/invoice.pdf"
)
private
String
invoiceUrl
;
@Schema
(
description
=
"CPU配置"
,
example
=
"Intel Xeon E5-2680 v4"
)
private
String
cpu
;
@Schema
(
description
=
"GPU配置"
,
example
=
"NVIDIA RTX 4090"
)
private
String
gpu
;
@Schema
(
description
=
"内存配置"
,
example
=
"64GB DDR4"
)
private
String
ram
;
@Schema
(
description
=
"存储配置"
,
example
=
"2TB NVMe SSD"
)
private
String
storage
;
@Schema
(
description
=
"服务器IP"
,
example
=
"192.168.1.100"
)
private
String
ip
;
@Schema
(
description
=
"服务器所在地"
,
example
=
"深圳"
)
private
String
location
;
@Schema
(
description
=
"备注"
,
example
=
"高性能GPU服务器,适合AI训练"
)
private
String
remark
;
@Schema
(
description
=
"创建时间"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
)
private
LocalDateTime
createTime
;
@Schema
(
description
=
"更新时间"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
)
private
LocalDateTime
updateTime
;
}
\ No newline at end of file
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/dal/mysql/resourceorder/ResourceOrderMapper.java
View file @
95512b4d
...
@@ -5,7 +5,9 @@ import java.util.*;
...
@@ -5,7 +5,9 @@ import java.util.*;
import
com.luhu.computility.framework.common.pojo.PageResult
;
import
com.luhu.computility.framework.common.pojo.PageResult
;
import
com.luhu.computility.framework.mybatis.core.query.LambdaQueryWrapperX
;
import
com.luhu.computility.framework.mybatis.core.query.LambdaQueryWrapperX
;
import
com.luhu.computility.framework.mybatis.core.mapper.BaseMapperX
;
import
com.luhu.computility.framework.mybatis.core.mapper.BaseMapperX
;
import
com.luhu.computility.framework.mybatis.core.query.MPJLambdaWrapperX
;
import
com.luhu.computility.module.compute.dal.dataobject.resourceorder.ResourceOrderDO
;
import
com.luhu.computility.module.compute.dal.dataobject.resourceorder.ResourceOrderDO
;
import
com.luhu.computility.module.member.dal.dataobject.user.MemberUserDO
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
com.luhu.computility.module.compute.controller.admin.resourceorder.vo.*
;
import
com.luhu.computility.module.compute.controller.admin.resourceorder.vo.*
;
...
@@ -17,7 +19,35 @@ import com.luhu.computility.module.compute.controller.admin.resourceorder.vo.*;
...
@@ -17,7 +19,35 @@ import com.luhu.computility.module.compute.controller.admin.resourceorder.vo.*;
@Mapper
@Mapper
public
interface
ResourceOrderMapper
extends
BaseMapperX
<
ResourceOrderDO
>
{
public
interface
ResourceOrderMapper
extends
BaseMapperX
<
ResourceOrderDO
>
{
default
PageResult
<
ResourceOrderDO
>
selectPage
(
ResourceOrderPageReqVO
reqVO
)
{
default
PageResult
<
ResourceOrderRespVO
>
selectPage
(
ResourceOrderPageReqVO
reqVO
)
{
return
selectJoinPage
(
reqVO
,
ResourceOrderRespVO
.
class
,
new
MPJLambdaWrapperX
<
ResourceOrderDO
>()
.
selectAll
(
ResourceOrderDO
.
class
)
.
selectAs
(
MemberUserDO:
:
getNickname
,
ResourceOrderRespVO:
:
getNickname
)
.
leftJoin
(
MemberUserDO
.
class
,
MemberUserDO:
:
getId
,
ResourceOrderDO:
:
getUserId
)
.
eqIfPresent
(
ResourceOrderDO:
:
getUserId
,
reqVO
.
getUserId
())
.
eqIfPresent
(
ResourceOrderDO:
:
getSkuId
,
reqVO
.
getSkuId
())
.
likeIfPresent
(
ResourceOrderDO:
:
getSpuName
,
reqVO
.
getSpuName
())
.
eqIfPresent
(
ResourceOrderDO:
:
getOrderNo
,
reqVO
.
getOrderNo
())
.
eqIfPresent
(
ResourceOrderDO:
:
getStatus
,
reqVO
.
getStatus
())
.
eqIfPresent
(
ResourceOrderDO:
:
getMarketPrice
,
reqVO
.
getMarketPrice
())
.
eqIfPresent
(
ResourceOrderDO:
:
getPaymentPrice
,
reqVO
.
getPaymentPrice
())
.
eqIfPresent
(
ResourceOrderDO:
:
getPayOrderId
,
reqVO
.
getPayOrderId
())
.
betweenIfPresent
(
ResourceOrderDO:
:
getPayTime
,
reqVO
.
getPayTime
())
.
eqIfPresent
(
ResourceOrderDO:
:
getPayChannelCode
,
reqVO
.
getPayChannelCode
())
.
betweenIfPresent
(
ResourceOrderDO:
:
getRentStartTime
,
reqVO
.
getRentStartTime
())
.
betweenIfPresent
(
ResourceOrderDO:
:
getRentEndTime
,
reqVO
.
getRentEndTime
())
.
betweenIfPresent
(
ResourceOrderDO:
:
getCancelTime
,
reqVO
.
getCancelTime
())
.
eqIfPresent
(
ResourceOrderDO:
:
getRemark
,
reqVO
.
getRemark
())
.
eqIfPresent
(
ResourceOrderDO:
:
getResourceStatus
,
reqVO
.
getResourceStatus
())
.
eqIfPresent
(
ResourceOrderDO:
:
getRefundStatus
,
reqVO
.
getRefundStatus
())
.
eqIfPresent
(
ResourceOrderDO:
:
getRefundPrice
,
reqVO
.
getRefundPrice
())
.
eqIfPresent
(
ResourceOrderDO:
:
getInvoiceStatus
,
reqVO
.
getInvoiceStatus
())
.
eqIfPresent
(
ResourceOrderDO:
:
getInvoiceUrl
,
reqVO
.
getInvoiceUrl
())
.
betweenIfPresent
(
ResourceOrderDO:
:
getCreateTime
,
reqVO
.
getCreateTime
())
.
orderByDesc
(
ResourceOrderDO:
:
getId
));
}
default
PageResult
<
ResourceOrderDO
>
selectPageDO
(
ResourceOrderPageReqVO
reqVO
)
{
return
selectPage
(
reqVO
,
new
LambdaQueryWrapperX
<
ResourceOrderDO
>()
return
selectPage
(
reqVO
,
new
LambdaQueryWrapperX
<
ResourceOrderDO
>()
.
eqIfPresent
(
ResourceOrderDO:
:
getUserId
,
reqVO
.
getUserId
())
.
eqIfPresent
(
ResourceOrderDO:
:
getUserId
,
reqVO
.
getUserId
())
.
eqIfPresent
(
ResourceOrderDO:
:
getSkuId
,
reqVO
.
getSkuId
())
.
eqIfPresent
(
ResourceOrderDO:
:
getSkuId
,
reqVO
.
getSkuId
())
...
...
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/dal/redis/RedisKeyConstants.java
0 → 100644
View file @
95512b4d
package
com
.
luhu
.
computility
.
module
.
compute
.
dal
.
redis
;
/**
* 算力资源 Redis Key 枚举类
*
* @author jony
*/
public
interface
RedisKeyConstants
{
/**
* 算力资源订单序号的缓存
*
* KEY 格式:compute_trade_no:{prefix}
* VALUE 数据格式:编号自增
*/
String
COMPUTE_TRADE_NO
=
"compute_trade_no:"
;
}
\ No newline at end of file
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/dal/redis/no/ResourceOrderNoRedisDAO.java
0 → 100644
View file @
95512b4d
package
com
.
luhu
.
computility
.
module
.
compute
.
dal
.
redis
.
no
;
import
cn.hutool.core.date.DatePattern
;
import
cn.hutool.core.date.DateUtil
;
import
com.luhu.computility.module.compute.dal.redis.RedisKeyConstants
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.stereotype.Repository
;
import
javax.annotation.Resource
;
import
java.time.Duration
;
/**
* 算力资源订单序号的 Redis DAO
*
* @author jony
*/
@Repository
public
class
ResourceOrderNoRedisDAO
{
public
static
final
String
RESOURCE_ORDER_NO_PREFIX
=
"a"
;
@Resource
private
StringRedisTemplate
stringRedisTemplate
;
/**
* 生成序号
*
* @param prefix 前缀
* @return 序号
*/
public
String
generate
(
String
prefix
)
{
// 递增序号
String
noPrefix
=
prefix
+
DateUtil
.
format
(
java
.
time
.
LocalDateTime
.
now
(),
DatePattern
.
PURE_DATETIME_PATTERN
);
String
key
=
RedisKeyConstants
.
COMPUTE_TRADE_NO
+
noPrefix
;
Long
no
=
stringRedisTemplate
.
opsForValue
().
increment
(
key
);
// 设置过期时间
stringRedisTemplate
.
expire
(
key
,
Duration
.
ofMinutes
(
1L
));
return
noPrefix
+
no
;
}
}
\ No newline at end of file
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/service/resourceorder/ResourceOrderService.java
View file @
95512b4d
...
@@ -7,6 +7,7 @@ import com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppRe
...
@@ -7,6 +7,7 @@ import com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppRe
import
com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppResourceOrderCreateRespVO
;
import
com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppResourceOrderCreateRespVO
;
import
com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppResourceOrderPageReqVO
;
import
com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppResourceOrderPageReqVO
;
import
com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppResourceOrderRespVO
;
import
com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppResourceOrderRespVO
;
import
com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppResourceOrderInvoiceReqVO
;
import
com.luhu.computility.module.compute.dal.dataobject.resourceorder.ResourceOrderDO
;
import
com.luhu.computility.module.compute.dal.dataobject.resourceorder.ResourceOrderDO
;
import
com.luhu.computility.framework.common.pojo.PageResult
;
import
com.luhu.computility.framework.common.pojo.PageResult
;
import
com.luhu.computility.framework.common.pojo.PageParam
;
import
com.luhu.computility.framework.common.pojo.PageParam
;
...
@@ -61,7 +62,7 @@ public interface ResourceOrderService {
...
@@ -61,7 +62,7 @@ public interface ResourceOrderService {
* @param pageReqVO 分页查询
* @param pageReqVO 分页查询
* @return 算力资源订单分页
* @return 算力资源订单分页
*/
*/
PageResult
<
ResourceOrder
D
O
>
getResourceOrderPage
(
ResourceOrderPageReqVO
pageReqVO
);
PageResult
<
ResourceOrder
RespV
O
>
getResourceOrderPage
(
ResourceOrderPageReqVO
pageReqVO
);
/**
/**
* 用户创建算力资源订单
* 用户创建算力资源订单
...
@@ -105,4 +106,20 @@ public interface ResourceOrderService {
...
@@ -105,4 +106,20 @@ public interface ResourceOrderService {
*/
*/
AppResourceOrderRespVO
getUserResourceOrder
(
Long
userId
,
Long
id
);
AppResourceOrderRespVO
getUserResourceOrder
(
Long
userId
,
Long
id
);
/**
* 更新开票状态
*
* @param saveVO 保存信息
* @return 是否成功
*/
boolean
updateInvoice
(
ResourceOrderSaveReqVO
saveVO
);
/**
* 用户申请开票
*
* @param reqVO 申请信息
* @return 是否成功
*/
boolean
updateRequestInvoice
(
AppResourceOrderInvoiceReqVO
reqVO
);
}
}
\ No newline at end of file
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/service/resourceorder/ResourceOrderServiceImpl.java
View file @
95512b4d
...
@@ -2,6 +2,11 @@ package com.luhu.computility.module.compute.service.resourceorder;
...
@@ -2,6 +2,11 @@ package com.luhu.computility.module.compute.service.resourceorder;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.luhu.computility.framework.common.exception.ServiceException
;
import
com.luhu.computility.framework.common.util.json.JsonUtils
;
import
com.luhu.computility.framework.common.util.string.StrUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
...
@@ -14,6 +19,7 @@ import com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppRe
...
@@ -14,6 +19,7 @@ import com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppRe
import
com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppResourceOrderCreateRespVO
;
import
com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppResourceOrderCreateRespVO
;
import
com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppResourceOrderPageReqVO
;
import
com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppResourceOrderPageReqVO
;
import
com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppResourceOrderRespVO
;
import
com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppResourceOrderRespVO
;
import
com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppResourceOrderInvoiceReqVO
;
import
com.luhu.computility.module.compute.dal.dataobject.resourceorder.ResourceOrderDO
;
import
com.luhu.computility.module.compute.dal.dataobject.resourceorder.ResourceOrderDO
;
import
com.luhu.computility.framework.common.pojo.PageResult
;
import
com.luhu.computility.framework.common.pojo.PageResult
;
import
com.luhu.computility.framework.common.pojo.PageParam
;
import
com.luhu.computility.framework.common.pojo.PageParam
;
...
@@ -31,6 +37,8 @@ import com.luhu.computility.module.compute.enums.ResourceOrderInvoiceStatus;
...
@@ -31,6 +37,8 @@ import com.luhu.computility.module.compute.enums.ResourceOrderInvoiceStatus;
import
com.luhu.computility.module.compute.config.ResourceOrderProperties
;
import
com.luhu.computility.module.compute.config.ResourceOrderProperties
;
import
com.luhu.computility.module.pay.api.order.PayOrderApi
;
import
com.luhu.computility.module.pay.api.order.PayOrderApi
;
import
com.luhu.computility.module.pay.api.order.dto.PayOrderCreateReqDTO
;
import
com.luhu.computility.module.pay.api.order.dto.PayOrderCreateReqDTO
;
import
com.luhu.computility.module.pay.api.order.dto.PayOrderRespDTO
;
import
com.luhu.computility.module.pay.enums.order.PayOrderStatusEnum
;
import
static
com
.
luhu
.
computility
.
framework
.
common
.
util
.
servlet
.
ServletUtils
.
getClientIP
;
import
static
com
.
luhu
.
computility
.
framework
.
common
.
util
.
servlet
.
ServletUtils
.
getClientIP
;
import
static
com
.
luhu
.
computility
.
framework
.
common
.
util
.
date
.
LocalDateTimeUtils
.
addTime
;
import
static
com
.
luhu
.
computility
.
framework
.
common
.
util
.
date
.
LocalDateTimeUtils
.
addTime
;
...
@@ -49,6 +57,7 @@ import com.luhu.computility.module.compute.dal.redis.no.ResourceOrderNoRedisDAO;
...
@@ -49,6 +57,7 @@ import com.luhu.computility.module.compute.dal.redis.no.ResourceOrderNoRedisDAO;
*/
*/
@Service
@Service
@Validated
@Validated
@Slf4j
public
class
ResourceOrderServiceImpl
implements
ResourceOrderService
{
public
class
ResourceOrderServiceImpl
implements
ResourceOrderService
{
@Resource
@Resource
...
@@ -106,10 +115,13 @@ public class ResourceOrderServiceImpl implements ResourceOrderService {
...
@@ -106,10 +115,13 @@ public class ResourceOrderServiceImpl implements ResourceOrderService {
}
}
private
void
validateResourceOrderExists
(
Long
id
)
{
private
ResourceOrderDO
validateResourceOrderExists
(
Long
id
)
{
if
(
resourceOrderMapper
.
selectById
(
id
)
==
null
)
{
// 校验算力资源订单是否存在
ResourceOrderDO
order
=
resourceOrderMapper
.
selectById
(
id
);
if
(
order
==
null
)
{
throw
exception
(
RESOURCE_ORDER_NOT_EXISTS
);
throw
exception
(
RESOURCE_ORDER_NOT_EXISTS
);
}
}
return
order
;
}
}
@Override
@Override
...
@@ -118,7 +130,7 @@ public class ResourceOrderServiceImpl implements ResourceOrderService {
...
@@ -118,7 +130,7 @@ public class ResourceOrderServiceImpl implements ResourceOrderService {
}
}
@Override
@Override
public
PageResult
<
ResourceOrder
D
O
>
getResourceOrderPage
(
ResourceOrderPageReqVO
pageReqVO
)
{
public
PageResult
<
ResourceOrder
RespV
O
>
getResourceOrderPage
(
ResourceOrderPageReqVO
pageReqVO
)
{
return
resourceOrderMapper
.
selectPage
(
pageReqVO
);
return
resourceOrderMapper
.
selectPage
(
pageReqVO
);
}
}
...
@@ -180,12 +192,11 @@ public class ResourceOrderServiceImpl implements ResourceOrderService {
...
@@ -180,12 +192,11 @@ public class ResourceOrderServiceImpl implements ResourceOrderService {
private
void
createPayOrder
(
ResourceOrderDO
order
)
{
private
void
createPayOrder
(
ResourceOrderDO
order
)
{
// 创建支付单,用于后续的支付
// 创建支付单,用于后续的支付
PayOrderCreateReqDTO
payOrderCreateReqDTO
=
new
PayOrderCreateReqDTO
()
PayOrderCreateReqDTO
payOrderCreateReqDTO
=
new
PayOrderCreateReqDTO
()
.
setAppKey
(
resourceOrderProperties
.
getPayAppKey
())
.
setAppKey
(
resourceOrderProperties
.
getPayAppKey
()).
setUserIp
(
order
.
getUserIp
());
.
setUserIp
(
order
.
getUserIp
());
// 商户相关字段
// 商户相关字段
payOrderCreateReqDTO
.
setMerchantOrderId
(
String
.
valueOf
(
order
.
getId
()));
payOrderCreateReqDTO
.
setMerchantOrderId
(
String
.
valueOf
(
order
.
getId
()));
String
subject
=
order
.
getSpuName
()
+
" - "
+
getDurationDaysFromSku
(
order
.
getSkuId
())
+
"天"
;
String
subject
=
order
.
getSpuName
()
+
" - "
+
getDurationDaysFromSku
(
order
.
getSkuId
())
+
"天"
;
subject
=
StrUtils
.
maxLength
(
subject
,
PayOrderCreateReqDTO
.
SUBJECT_MAX_LENGTH
);
// 避免超过 32 位
payOrderCreateReqDTO
.
setSubject
(
subject
);
payOrderCreateReqDTO
.
setSubject
(
subject
);
payOrderCreateReqDTO
.
setBody
(
subject
);
payOrderCreateReqDTO
.
setBody
(
subject
);
...
@@ -208,23 +219,23 @@ public class ResourceOrderServiceImpl implements ResourceOrderService {
...
@@ -208,23 +219,23 @@ public class ResourceOrderServiceImpl implements ResourceOrderService {
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updateOrderPaid
(
Long
orderId
,
Long
payOrderId
)
{
public
void
updateOrderPaid
(
Long
orderId
,
Long
payOrderId
)
{
// 校验订单存在
// 1.1 校验算力资源订单是否存在
ResourceOrderDO
order
=
resourceOrderMapper
.
selectById
(
orderId
);
ResourceOrderDO
order
=
validateResourceOrderExists
(
orderId
);
if
(
order
==
null
)
{
// 1.2 校验算力资源订单已支付
throw
exception
(
RESOURCE_ORDER_NOT_EXISTS
);
if
(
ResourceOrderStatus
.
PAID
.
getValue
()
==
order
.
getStatus
())
{
// 特殊:支付单号相同,直接返回,说明重复回调
if
(
Objects
.
equals
(
order
.
getPayOrderId
(),
payOrderId
))
{
log
.
warn
(
"[updateOrderPaid][order({}) 已支付,且支付单号相同({}),直接返回]"
,
order
,
payOrderId
);
return
;
}
}
log
.
error
(
"[updateOrderPaid][order({}) 支付单不匹配({}),请进行处理!order 数据是:{}]"
,
// 校验订单状态
orderId
,
payOrderId
,
JsonUtils
.
toJsonString
(
order
));
if
(!
order
.
getStatus
().
equals
(
ResourceOrderStatus
.
UNPAID
.
getValue
()))
{
throw
exception
(
RESOURCE_ORDER_STATUS_NOT_UNPAID
);
}
}
// 校验支付订单ID匹配
// 2. 校验支付订单的合法性
if
(!
Objects
.
equals
(
order
.
getPayOrderId
(),
payOrderId
))
{
PayOrderRespDTO
payOrder
=
validatePayOrderPaid
(
order
,
payOrderId
);
throw
exception
(
RESOURCE_ORDER_PAY_ORDER_ID_MISMATCH
);
}
//
更新订单状态
//
3. 更新算力资源订单状态为已支付
ResourceOrderDO
updateOrder
=
new
ResourceOrderDO
();
ResourceOrderDO
updateOrder
=
new
ResourceOrderDO
();
updateOrder
.
setId
(
orderId
);
updateOrder
.
setId
(
orderId
);
updateOrder
.
setStatus
(
ResourceOrderStatus
.
PAID
.
getValue
());
updateOrder
.
setStatus
(
ResourceOrderStatus
.
PAID
.
getValue
());
...
@@ -267,10 +278,46 @@ public class ResourceOrderServiceImpl implements ResourceOrderService {
...
@@ -267,10 +278,46 @@ public class ResourceOrderServiceImpl implements ResourceOrderService {
return
resourceOrderNoRedisDAO
.
generate
(
ResourceOrderNoRedisDAO
.
RESOURCE_ORDER_NO_PREFIX
);
return
resourceOrderNoRedisDAO
.
generate
(
ResourceOrderNoRedisDAO
.
RESOURCE_ORDER_NO_PREFIX
);
}
}
/**
* 校验支付订单的合法性
*
* @param order 交易订单
* @param payOrderId 支付订单编号
* @return 支付订单
*/
private
PayOrderRespDTO
validatePayOrderPaid
(
ResourceOrderDO
order
,
Long
payOrderId
)
{
// 1. 校验支付单是否存在
PayOrderRespDTO
payOrder
=
payOrderApi
.
getOrder
(
payOrderId
);
if
(
payOrder
==
null
)
{
log
.
error
(
"[validatePayOrderPaid][order({}) payOrder({}) 不存在,请进行处理!]"
,
order
.
getId
(),
payOrderId
);
throw
exception
(
RESOURCE_ORDER_NOT_EXISTS
);
}
// 2.1 校验支付单已支付
if
(!
PayOrderStatusEnum
.
isSuccess
(
payOrder
.
getStatus
()))
{
log
.
error
(
"[validatePayOrderPaid][order({}) payOrder({}) 未支付,请进行处理!payOrder 数据是:{}]"
,
order
.
getId
(),
payOrderId
,
JsonUtils
.
toJsonString
(
payOrder
));
throw
exception
(
RESOURCE_ORDER_STATUS_NOT_UNPAID
);
}
// 2.2 校验支付金额一致
if
(
ObjectUtil
.
notEqual
(
payOrder
.
getPrice
(),
order
.
getPaymentPrice
().
intValue
()))
{
log
.
error
(
"[validatePayOrderPaid][order({}) payOrder({}) 算力资源订单支付金额不匹配,请进行处理!order 数据是:{},payOrder 数据是:{}]"
,
order
.
getId
(),
payOrderId
,
JsonUtils
.
toJsonString
(
order
),
JsonUtils
.
toJsonString
(
payOrder
));
throw
exception
(
RESOURCE_ORDER_STATUS_NOT_UNPAID
);
}
// 2.2 校验支付订单匹配(二次)
if
(
ObjectUtil
.
notEqual
(
payOrder
.
getMerchantOrderId
(),
order
.
getId
().
toString
()))
{
log
.
error
(
"[validatePayOrderPaid][order({}) 算力资源支付单不匹配({}),请进行处理!payOrder 数据是:{}]"
,
order
.
getId
(),
payOrderId
,
JsonUtils
.
toJsonString
(
payOrder
));
throw
exception
(
RESOURCE_ORDER_PAY_ORDER_ID_MISMATCH
);
}
return
payOrder
;
}
@Override
@Override
public
PageResult
<
AppResourceOrderRespVO
>
getUserResourceOrderPage
(
AppResourceOrderPageReqVO
pageReqVO
)
{
public
PageResult
<
AppResourceOrderRespVO
>
getUserResourceOrderPage
(
AppResourceOrderPageReqVO
pageReqVO
)
{
// 查询订单分页
// 查询订单分页
PageResult
<
ResourceOrderDO
>
pageResult
=
resourceOrderMapper
.
selectPage
(
BeanUtils
.
toBean
(
pageReqVO
,
ResourceOrderPageReqVO
.
class
));
PageResult
<
ResourceOrderDO
>
pageResult
=
resourceOrderMapper
.
selectPage
DO
(
BeanUtils
.
toBean
(
pageReqVO
,
ResourceOrderPageReqVO
.
class
));
if
(
CollUtil
.
isEmpty
(
pageResult
.
getList
()))
{
if
(
CollUtil
.
isEmpty
(
pageResult
.
getList
()))
{
return
new
PageResult
<>(
Collections
.
emptyList
(),
pageResult
.
getTotal
());
return
new
PageResult
<>(
Collections
.
emptyList
(),
pageResult
.
getTotal
());
...
@@ -358,4 +405,33 @@ public class ResourceOrderServiceImpl implements ResourceOrderService {
...
@@ -358,4 +405,33 @@ public class ResourceOrderServiceImpl implements ResourceOrderService {
return
respVO
;
return
respVO
;
}
}
@Override
public
boolean
updateInvoice
(
ResourceOrderSaveReqVO
saveVO
)
{
ResourceOrderDO
order
=
resourceOrderMapper
.
selectById
(
saveVO
.
getId
());
if
(!
Objects
.
equals
(
order
.
getStatus
(),
ResourceOrderStatus
.
PAID
.
getValue
()))
{
throw
new
ServiceException
(
"只有已支付的订单可以开票!"
);
}
order
.
setInvoiceStatus
(
ResourceOrderInvoiceStatus
.
INVOICED
.
getValue
());
order
.
setInvoiceUrl
(
saveVO
.
getInvoiceUrl
());
resourceOrderMapper
.
updateById
(
order
);
return
true
;
}
@Override
public
boolean
updateRequestInvoice
(
AppResourceOrderInvoiceReqVO
reqVO
)
{
ResourceOrderDO
resourceOrderDO
=
resourceOrderMapper
.
selectById
(
reqVO
.
getId
());
if
(
resourceOrderDO
==
null
)
{
throw
new
ServiceException
(
"订单不存在,请检查订单ID是否正确"
);
}
Integer
status
=
resourceOrderDO
.
getStatus
();
if
(
status
.
equals
(
ResourceOrderStatus
.
UNPAID
.
getValue
()))
{
throw
new
ServiceException
(
"未支付的订单不能申请开票"
);
}
else
if
(
status
.
equals
(
ResourceOrderStatus
.
CANCELED
.
getValue
()))
{
throw
new
ServiceException
(
"已取消的订单不能申请开票!"
);
}
resourceOrderDO
.
setInvoiceStatus
(
ResourceOrderInvoiceStatus
.
INVOICING
.
getValue
());
resourceOrderMapper
.
updateById
(
resourceOrderDO
);
return
true
;
}
}
}
\ No newline at end of file
computility-module-mall/computility-module-trade/src/main/java/com/luhu/computility/module/trade/controller/app/order/AppTradeOrderController.java
View file @
95512b4d
package
com
.
luhu
.
computility
.
module
.
trade
.
controller
.
app
.
order
;
package
com
.
luhu
.
computility
.
module
.
trade
.
controller
.
app
.
order
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.google.common.collect.Maps
;
import
com.luhu.computility.framework.common.exception.ServiceException
;
import
com.luhu.computility.framework.common.exception.ServiceException
;
import
com.luhu.computility.framework.common.pojo.CommonResult
;
import
com.luhu.computility.framework.common.pojo.CommonResult
;
import
com.luhu.computility.framework.common.pojo.PageResult
;
import
com.luhu.computility.framework.common.pojo.PageResult
;
...
@@ -12,26 +13,21 @@ import com.luhu.computility.module.trade.controller.app.order.vo.*;
...
@@ -12,26 +13,21 @@ import com.luhu.computility.module.trade.controller.app.order.vo.*;
import
com.luhu.computility.module.trade.controller.app.order.vo.item.AppTradeOrderItemCommentCreateReqVO
;
import
com.luhu.computility.module.trade.controller.app.order.vo.item.AppTradeOrderItemCommentCreateReqVO
;
import
com.luhu.computility.module.trade.controller.app.order.vo.item.AppTradeOrderItemRespVO
;
import
com.luhu.computility.module.trade.controller.app.order.vo.item.AppTradeOrderItemRespVO
;
import
com.luhu.computility.module.trade.convert.order.TradeOrderConvert
;
import
com.luhu.computility.module.trade.convert.order.TradeOrderConvert
;
import
com.luhu.computility.module.trade.dal.dataobject.delivery.DeliveryExpressDO
;
import
com.luhu.computility.module.trade.dal.dataobject.order.TradeOrderDO
;
import
com.luhu.computility.module.trade.dal.dataobject.order.TradeOrderDO
;
import
com.luhu.computility.module.trade.dal.dataobject.order.TradeOrderItemDO
;
import
com.luhu.computility.module.trade.dal.dataobject.order.TradeOrderItemDO
;
import
com.luhu.computility.module.trade.enums.order.TradeOrderInvoiceStatusEnum
;
import
com.luhu.computility.module.trade.enums.order.TradeOrderInvoiceStatusEnum
;
import
com.luhu.computility.module.trade.enums.order.TradeOrderStatusEnum
;
import
com.luhu.computility.module.trade.enums.order.TradeOrderStatusEnum
;
import
com.luhu.computility.module.trade.enums.order.TradeOrderTypeEnum
;
import
com.luhu.computility.module.trade.framework.order.config.TradeOrderProperties
;
import
com.luhu.computility.module.trade.framework.order.config.TradeOrderProperties
;
import
com.luhu.computility.module.trade.service.aftersale.AfterSaleService
;
import
com.luhu.computility.module.trade.service.aftersale.AfterSaleService
;
import
com.luhu.computility.module.trade.service.delivery.DeliveryExpressService
;
import
com.luhu.computility.module.trade.service.delivery.DeliveryExpressService
;
import
com.luhu.computility.module.trade.service.order.TradeOrderQueryService
;
import
com.luhu.computility.module.trade.service.order.TradeOrderQueryService
;
import
com.luhu.computility.module.trade.service.order.TradeOrderToResourceService
;
import
com.luhu.computility.module.trade.service.order.TradeOrderUpdateService
;
import
com.luhu.computility.module.trade.service.order.TradeOrderUpdateService
;
import
com.luhu.computility.module.trade.service.price.TradePriceService
;
import
com.luhu.computility.module.trade.service.price.TradePriceService
;
import
com.google.common.collect.Maps
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.Parameter
;
import
io.swagger.v3.oas.annotations.Parameter
;
import
io.swagger.v3.oas.annotations.Parameters
;
import
io.swagger.v3.oas.annotations.Parameters
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.checkerframework.checker.units.qual.C
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
...
...
computility-module-mall/computility-module-trade/src/main/java/com/luhu/computility/module/trade/service/order/TradeOrderUpdateServiceImpl.java
View file @
95512b4d
...
@@ -802,6 +802,9 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
...
@@ -802,6 +802,9 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
@Override
@Override
public
boolean
updateRequestInvoice
(
AppTradeOrderInvoiceReqVO
reqVO
)
{
public
boolean
updateRequestInvoice
(
AppTradeOrderInvoiceReqVO
reqVO
)
{
TradeOrderDO
tradeOrderDO
=
tradeOrderMapper
.
selectById
(
reqVO
.
getId
());
TradeOrderDO
tradeOrderDO
=
tradeOrderMapper
.
selectById
(
reqVO
.
getId
());
if
(
tradeOrderDO
==
null
)
{
throw
new
ServiceException
(
"订单不存在,请检查订单ID是否正确"
);
}
Integer
status
=
tradeOrderDO
.
getStatus
();
//订单状态
Integer
status
=
tradeOrderDO
.
getStatus
();
//订单状态
if
(
status
.
equals
(
UNPAID
.
getStatus
())){
if
(
status
.
equals
(
UNPAID
.
getStatus
())){
throw
new
ServiceException
(
"未支付的订单不能申请开票"
);
throw
new
ServiceException
(
"未支付的订单不能申请开票"
);
...
...
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