Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
usedCarAuction
/
aus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 7dffb960
authored
Aug 06, 2026
by
章家宝
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat:需求《中拍后链路缩减操作步骤》代码开发第一版提交
1 parent
54e78350
Hide whitespace changes
Inline
Side-by-side
Showing
34 changed files
with
2338 additions
and
95 deletions
aus-admin/src/main/java/com/glsx/usedcar/web/rest/account/PlatformContractController.java
aus-admin/src/main/java/com/glsx/usedcar/web/rest/auction/AuctionOrderController.java
aus-api/src/main/java/com/glsx/usedcar/web/api/account/AccountController.java
aus-api/src/main/java/com/glsx/usedcar/web/api/account/PlatformContractController.java
aus-api/src/main/java/com/glsx/usedcar/web/api/auction/AuctionOrderController.java
aus-api/src/main/java/com/glsx/usedcar/web/api/esign/ESignController.java
aus-core/src/main/java/com/glsx/usedcar/converts/PlatformContractConverter.java
aus-core/src/main/java/com/glsx/usedcar/esign/DocTemplateRequest.java
aus-core/src/main/java/com/glsx/usedcar/gsc/ReceiveClient.java
aus-core/src/main/java/com/glsx/usedcar/module/account/dao/PlatformContractDao.java
aus-core/src/main/java/com/glsx/usedcar/module/account/domain/AccountInfo.java
aus-core/src/main/java/com/glsx/usedcar/module/account/entity/Account.java
aus-core/src/main/java/com/glsx/usedcar/module/account/entity/PlatformContract.java
aus-core/src/main/java/com/glsx/usedcar/module/account/service/AccountService.java
aus-core/src/main/java/com/glsx/usedcar/module/account/service/PlatformContractService.java
aus-core/src/main/java/com/glsx/usedcar/module/account/vo/PlatformContractPageQueryVO.java
aus-core/src/main/java/com/glsx/usedcar/module/account/vo/PlatformContractPageRespVO.java
aus-core/src/main/java/com/glsx/usedcar/module/account/vo/PlatformContractRespVO.java
aus-core/src/main/java/com/glsx/usedcar/module/auction/entity/AuctionOrder.java
aus-core/src/main/java/com/glsx/usedcar/module/auction/entity/ContractTemplate.java
aus-core/src/main/java/com/glsx/usedcar/module/auction/entity/vo/ProxyUploadPayVoucherVO.java
aus-core/src/main/java/com/glsx/usedcar/module/auction/entity/vo/ProxyUploadTransferMaterialsVO.java
aus-core/src/main/java/com/glsx/usedcar/module/auction/entity/vo/UpdateVehicleDocumentsVO.java
aus-core/src/main/java/com/glsx/usedcar/module/auction/service/AuctionOrderService.java
aus-core/src/main/java/com/glsx/usedcar/module/auction/service/BidService.java
aus-core/src/main/java/com/glsx/usedcar/module/auction/service/ContractService.java
aus-core/src/main/java/com/glsx/usedcar/module/auction/service/DeliveryOrderService.java
aus-core/src/main/java/com/glsx/usedcar/module/business/entity/Agreement.java
aus-core/src/main/java/com/glsx/usedcar/module/business/service/AgreementService.java
aus-core/src/main/java/com/glsx/usedcar/module/vehicle/entity/TransferMaterials.java
aus-core/src/main/java/com/glsx/usedcar/module/vehicle/entity/Vehicle.java
aus-core/src/main/java/com/glsx/usedcar/module/vehicle/service/VehicleService.java
aus-core/src/main/java/com/glsx/usedcar/module/vrsystem/service/VrAuditService.java
aus-task/src/main/java/com/glsx/usedcar/task/TransferMaterialsSyncSchedule.java
aus-admin/src/main/java/com/glsx/usedcar/web/rest/account/PlatformContractController.java
0 → 100644
View file @
7dffb96
package
com
.
glsx
.
usedcar
.
web
.
rest
.
account
;
import
com.glsx.usedcar.module.account.entity.Account
;
import
com.glsx.usedcar.module.account.entity.Account_
;
import
com.glsx.usedcar.module.account.entity.PlatformContract
;
import
com.glsx.usedcar.module.account.entity.PlatformContract_
;
import
com.glsx.usedcar.module.account.service.PlatformContractService
;
import
com.glsx.usedcar.module.account.vo.PlatformContractPageQueryVO
;
import
com.glsx.usedcar.module.account.vo.PlatformContractPageRespVO
;
import
com.glsx.usedcar.module.account.vo.PlatformContractRespVO
;
import
com.glsx.usedcar.resp.BaseResp
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.Parameter
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.data.domain.Page
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.bind.annotation.*
;
import
org.summerframework.orm.paging.Operator
;
import
org.summerframework.orm.paging.Pagination
;
import
java.time.LocalDateTime
;
import
java.util.List
;
/**
* 平台合同管理接口
* <p>
* 平台交易整体合同的列表查询、详情查看等功能
* </p>
*
* @author yangwei
* @since 2026-08-04
*/
@Slf4j
@RestController
@RequestMapping
(
"/rest/platformContract"
)
@RequiredArgsConstructor
@Tag
(
name
=
"平台合同管理"
,
description
=
"平台合同的查询操作"
)
public
class
PlatformContractController
{
private
final
PlatformContractService
platformContractService
;
/**
* 分页查询平台合同列表
*
* @param queryVO 分页查询参数
* @return 平台合同分页列表
*/
@PostMapping
(
"/page"
)
@Operation
(
summary
=
"分页查询平台合同"
,
description
=
"支持按合同编号/签署人姓名/手机号/状态/账户ID筛选"
)
public
BaseResp
<
Page
<
PlatformContractPageRespVO
>>
page
(
@RequestBody
PlatformContractPageQueryVO
queryVO
)
{
Pagination
<
PlatformContract
>
pagination
=
buildPagination
(
queryVO
);
// 关联查询账户信息
pagination
.
addFetch
(
root
->
root
.
fetch
(
PlatformContract_
.
account
,
jakarta
.
persistence
.
criteria
.
JoinType
.
LEFT
));
Page
<
PlatformContractPageRespVO
>
result
=
platformContractService
.
pagePlatformContractVO
(
pagination
);
return
BaseResp
.
success
(
result
);
}
/**
* 根据ID查询平台合同详情
*
* @param platformContractId 平台合同ID
* @return 平台合同详情
*/
@GetMapping
(
"/detail/{id}"
)
@Operation
(
summary
=
"查询平台合同详情"
,
description
=
"根据平台合同ID查询详情信息"
)
public
BaseResp
<
PlatformContractRespVO
>
detail
(
@Parameter
(
description
=
"平台合同ID"
,
required
=
true
,
example
=
"1"
)
@PathVariable
(
"id"
)
int
platformContractId
)
{
PlatformContractRespVO
result
=
platformContractService
.
getPlatformContractVOById
(
platformContractId
);
return
BaseResp
.
success
(
result
);
}
/**
* 根据账户ID查询平台合同列表
*
* @param accountId 账户ID
* @return 平台合同列表
*/
@GetMapping
(
"/listByAccount/{accountId}"
)
@Operation
(
summary
=
"查询账户的平台合同"
,
description
=
"根据账户ID查询该账户的所有平台合同"
)
public
BaseResp
<
List
<
PlatformContractRespVO
>>
listByAccount
(
@Parameter
(
description
=
"账户ID"
,
required
=
true
,
example
=
"1"
)
@PathVariable
int
accountId
)
{
List
<
PlatformContractRespVO
>
contracts
=
platformContractService
.
getPlatformContractVOsByAccountId
(
accountId
);
return
BaseResp
.
success
(
contracts
);
}
/**
* 检查账户是否已签署平台合同
*
* @param accountId 账户ID
* @return 是否已签署
*/
@GetMapping
(
"/checkSigned"
)
@Operation
(
summary
=
"检查账户是否已签署平台合同"
,
description
=
"根据账户ID检查该账户是否已签署平台合同"
)
public
BaseResp
<
Boolean
>
checkSigned
(
@Parameter
(
description
=
"账户ID"
,
required
=
true
,
example
=
"1"
)
@RequestParam
int
accountId
)
{
return
BaseResp
.
success
(
platformContractService
.
hasSignedPlatformContract
(
accountId
));
}
/**
* 构建分页查询参数
*/
private
Pagination
<
PlatformContract
>
buildPagination
(
PlatformContractPageQueryVO
queryVO
)
{
int
page
=
queryVO
.
getPage
()
==
null
||
queryVO
.
getPage
()
<
1
?
1
:
queryVO
.
getPage
();
int
size
=
queryVO
.
getSize
()
==
null
||
queryVO
.
getSize
()
<
1
?
20
:
queryVO
.
getSize
();
Pagination
<
PlatformContract
>
pagination
=
new
Pagination
<>((
page
-
1
)
*
size
,
size
);
pagination
.
setSort
(
"createTime"
);
pagination
.
setOrder
(
"desc"
);
// 合同编号筛选
if
(
StringUtils
.
hasText
(
queryVO
.
getContractCode
()))
{
pagination
.
addFilter
(
PlatformContract_
.
CONTRACT_CODE
,
queryVO
.
getContractCode
(),
Operator
.
like
);
}
// 签署人姓名筛选
if
(
StringUtils
.
hasText
(
queryVO
.
getSignerName
()))
{
pagination
.
addFilter
(
PlatformContract_
.
SIGNER_NAME
,
queryVO
.
getSignerName
(),
Operator
.
like
);
}
// 签署人手机号筛选
if
(
StringUtils
.
hasText
(
queryVO
.
getSignerMobile
()))
{
pagination
.
addFilter
(
PlatformContract_
.
SIGNER_MOBILE
,
queryVO
.
getSignerMobile
(),
Operator
.
eq
);
}
// 合同状态筛选
if
(
StringUtils
.
hasText
(
queryVO
.
getContractStatus
()))
{
pagination
.
addFilter
(
PlatformContract_
.
CONTRACT_STATUS
,
PlatformContract
.
ContractStatus
.
valueOf
(
queryVO
.
getContractStatus
()),
Operator
.
eq
);
}
// 账户ID筛选
if
(
queryVO
.
getAccountId
()
!=
null
)
{
pagination
.
addFilter
(
PlatformContract_
.
ACCOUNT
,
new
Account
(
queryVO
.
getAccountId
()),
Operator
.
eq
);
}
// 账户名称筛选
if
(
StringUtils
.
hasText
(
queryVO
.
getAccountName
()))
{
pagination
.
addCondition
((
root
,
query
,
builder
)
->
{
var
accountPath
=
root
.
get
(
PlatformContract_
.
account
).
get
(
Account_
.
ACCOUNT_NAME
);
return
builder
.
like
(
accountPath
,
"%"
+
queryVO
.
getAccountName
()
+
"%"
);
});
}
// 创建时间范围筛选
if
(
queryVO
.
getCreateTimeStart
()
!=
null
)
{
LocalDateTime
startTime
=
queryVO
.
getCreateTimeStart
().
atStartOfDay
();
pagination
.
addFilter
(
"createTime"
,
startTime
,
Operator
.
ge
);
}
if
(
queryVO
.
getCreateTimeEnd
()
!=
null
)
{
LocalDateTime
endTime
=
queryVO
.
getCreateTimeEnd
().
atTime
(
23
,
59
,
59
);
pagination
.
addFilter
(
"createTime"
,
endTime
,
Operator
.
le
);
}
return
pagination
;
}
}
aus-admin/src/main/java/com/glsx/usedcar/web/rest/auction/AuctionOrderController.java
View file @
7dffb96
...
@@ -6,6 +6,9 @@ import com.glsx.usedcar.module.auction.domain.BidOrder;
...
@@ -6,6 +6,9 @@ import com.glsx.usedcar.module.auction.domain.BidOrder;
import
com.glsx.usedcar.module.auction.entity.AuctionOrder
;
import
com.glsx.usedcar.module.auction.entity.AuctionOrder
;
import
com.glsx.usedcar.module.auction.entity.AuctionOrder_
;
import
com.glsx.usedcar.module.auction.entity.AuctionOrder_
;
import
com.glsx.usedcar.module.auction.entity.vo.AuctionOrderStateCountRespVO
;
import
com.glsx.usedcar.module.auction.entity.vo.AuctionOrderStateCountRespVO
;
import
com.glsx.usedcar.module.auction.entity.vo.ProxyUploadPayVoucherVO
;
import
com.glsx.usedcar.module.auction.entity.vo.ProxyUploadTransferMaterialsVO
;
import
com.glsx.usedcar.module.auction.entity.vo.UpdateVehicleDocumentsVO
;
import
com.glsx.usedcar.module.auction.entity.Auction_
;
import
com.glsx.usedcar.module.auction.entity.Auction_
;
import
com.glsx.usedcar.module.auction.service.AuctionOrderService
;
import
com.glsx.usedcar.module.auction.service.AuctionOrderService
;
import
com.glsx.usedcar.module.auction.service.AuctionService
;
import
com.glsx.usedcar.module.auction.service.AuctionService
;
...
@@ -176,4 +179,127 @@ public class AuctionOrderController {
...
@@ -176,4 +179,127 @@ public class AuctionOrderController {
List
<
AuctionOrderBean
>
vehicleBeans
=
vehicles
.
stream
().
map
(
AuctionOrderBean:
:
new
).
toList
();
List
<
AuctionOrderBean
>
vehicleBeans
=
vehicles
.
stream
().
map
(
AuctionOrderBean:
:
new
).
toList
();
ExcelExporter
.
exportExcel
(
response
,
"订单列表"
,
"订单列表"
,
AuctionOrderBean
.
class
,
vehicleBeans
);
ExcelExporter
.
exportExcel
(
response
,
"订单列表"
,
"订单列表"
,
AuctionOrderBean
.
class
,
vehicleBeans
);
}
}
/**
* 后台代上传付款凭证
* <p>
* 仅当订单状态为待付款且付款凭证数为0时可操作
* </p>
*
* @param vo 请求参数
* @return 更新后的订单
*/
@PostMapping
(
"proxyUploadPayVoucher"
)
@Operation
(
summary
=
"后台代上传付款凭证"
,
description
=
"仅当订单状态为待付款且付款凭证数为0时可操作"
)
public
BaseResp
<
AuctionOrder
>
proxyUploadPayVoucher
(
@Valid
@RequestBody
ProxyUploadPayVoucherVO
vo
)
{
log
.
info
(
"后台代上传付款凭证, 请求参数: {}"
,
vo
);
try
{
AuctionOrder
order
=
auctionOrderService
.
getAuctionOrderById
(
vo
.
getOrderId
());
// 校验订单状态
if
(
order
.
getOrderState
()
!=
AuctionOrder
.
OrderState
.
UNPAID
)
{
log
.
warn
(
"后台代上传付款凭证失败, 订单状态不正确, orderId: {}, orderState: {}"
,
vo
.
getOrderId
(),
order
.
getOrderState
());
return
BaseResp
.
fail
(
"订单状态不正确,仅待付款订单可上传付款凭证"
);
}
// 校验是否已有付款凭证
if
(
order
.
getPayVouchers
()
!=
null
&&
!
order
.
getPayVouchers
().
isEmpty
())
{
log
.
warn
(
"后台代上传付款凭证失败, 订单已有付款凭证, orderId: {}"
,
vo
.
getOrderId
());
return
BaseResp
.
fail
(
"订单已有付款凭证,不可重复上传"
);
}
// 更新付款凭证
order
.
setPayVouchers
(
vo
.
getPayVouchers
());
auctionOrderService
.
updateAuctionOrder
(
order
);
log
.
info
(
"后台代上传付款凭证成功, orderId: {}"
,
vo
.
getOrderId
());
return
BaseResp
.
success
(
order
);
}
catch
(
Exception
e
)
{
log
.
error
(
"后台代上传付款凭证失败, 请求参数: {}"
,
vo
,
e
);
return
BaseResp
.
fail
(
"上传失败:"
+
e
.
getMessage
());
}
}
/**
* 后台代上传过户资料
* <p>
* 仅当订单状态为待过户或审核中时可操作
* </p>
*
* @param vo 请求参数
* @return 更新后的订单
*/
@PostMapping
(
"proxyUploadTransferMaterials"
)
@Operation
(
summary
=
"后台代上传过户资料"
,
description
=
"仅当订单状态为待过户或审核中时可操作"
)
public
BaseResp
<
AuctionOrder
>
proxyUploadTransferMaterials
(
@Valid
@RequestBody
ProxyUploadTransferMaterialsVO
vo
)
{
log
.
info
(
"后台代上传过户资料, 请求参数: {}"
,
vo
);
try
{
AuctionOrder
order
=
auctionOrderService
.
getAuctionOrderById
(
vo
.
getOrderId
());
// 校验订单状态
if
(
order
.
getOrderState
()
!=
AuctionOrder
.
OrderState
.
TRANSFERRING
)
{
log
.
warn
(
"后台代上传过户资料失败, 订单状态不正确, orderId: {}, orderState: {}"
,
vo
.
getOrderId
(),
order
.
getOrderState
());
return
BaseResp
.
fail
(
"订单状态不正确,仅待过户订单可上传过户资料"
);
}
// 更新过户资料(保存但不触发审核)
if
(
vo
.
getNewPlateNumber
()
!=
null
)
{
order
.
setNewPlateNumber
(
vo
.
getNewPlateNumber
());
}
if
(
vo
.
getRegistrationCertificate
()
!=
null
)
{
order
.
setRegistrationCertificate
(
vo
.
getRegistrationCertificate
());
}
if
(
vo
.
getVehicleLicense
()
!=
null
)
{
order
.
setVehicleLicense
(
vo
.
getVehicleLicense
());
}
if
(
vo
.
getTransferInvoice
()
!=
null
)
{
order
.
setTransferInvoice
(
vo
.
getTransferInvoice
());
}
if
(
vo
.
getNewOwnerIdCard
()
!=
null
)
{
order
.
setNewOwnerIdCard
(
vo
.
getNewOwnerIdCard
());
}
auctionOrderService
.
updateAuctionOrder
(
order
);
log
.
info
(
"后台代上传过户资料成功, orderId: {}"
,
vo
.
getOrderId
());
return
BaseResp
.
success
(
order
);
}
catch
(
Exception
e
)
{
log
.
error
(
"后台代上传过户资料失败, 请求参数: {}"
,
vo
,
e
);
return
BaseResp
.
fail
(
"上传失败:"
+
e
.
getMessage
());
}
}
/**
* 更新车务资料(机动车登记证书、行驶证)
* <p>
* 用于后台修改订单的机动车登记证书和行驶证信息
* </p>
*
* @param vo 请求参数
* @return 更新后的订单
*/
@PostMapping
(
"updateVehicleDocuments"
)
@Operation
(
summary
=
"更新车务资料"
,
description
=
"修改订单的机动车登记证书和行驶证信息"
)
public
BaseResp
<
AuctionOrder
>
updateVehicleDocuments
(
@Valid
@RequestBody
UpdateVehicleDocumentsVO
vo
)
{
log
.
info
(
"更新车务资料, 请求参数: {}"
,
vo
);
try
{
AuctionOrder
order
=
auctionOrderService
.
getAuctionOrderById
(
vo
.
getOrderId
());
if
(
order
==
null
)
{
log
.
warn
(
"更新车务资料失败, 订单不存在, orderId: {}"
,
vo
.
getOrderId
());
return
BaseResp
.
fail
(
"订单不存在"
);
}
// 更新车务资料
order
.
setRegistrationCertificate
(
vo
.
getRegistrationCertificate
());
order
.
setVehicleLicense
(
vo
.
getVehicleLicense
());
auctionOrderService
.
updateAuctionOrder
(
order
);
log
.
info
(
"更新车务资料成功, orderId: {}"
,
vo
.
getOrderId
());
return
BaseResp
.
success
(
order
);
}
catch
(
Exception
e
)
{
log
.
error
(
"更新车务资料失败, 请求参数: {}"
,
vo
,
e
);
return
BaseResp
.
fail
(
"更新失败:"
+
e
.
getMessage
());
}
}
}
}
\ No newline at end of file
\ No newline at end of file
aus-api/src/main/java/com/glsx/usedcar/web/api/account/AccountController.java
View file @
7dffb96
...
@@ -8,6 +8,7 @@ import com.glsx.usedcar.module.account.entity.Account;
...
@@ -8,6 +8,7 @@ import com.glsx.usedcar.module.account.entity.Account;
import
com.glsx.usedcar.module.account.entity.AccountTag
;
import
com.glsx.usedcar.module.account.entity.AccountTag
;
import
com.glsx.usedcar.module.account.service.AccountService
;
import
com.glsx.usedcar.module.account.service.AccountService
;
import
com.glsx.usedcar.module.account.service.FavoriteService
;
import
com.glsx.usedcar.module.account.service.FavoriteService
;
import
com.glsx.usedcar.module.account.service.PlatformContractService
;
import
com.glsx.usedcar.module.auction.service.AuctionOrderService
;
import
com.glsx.usedcar.module.auction.service.AuctionOrderService
;
import
com.glsx.usedcar.module.auction.service.BidService
;
import
com.glsx.usedcar.module.auction.service.BidService
;
import
com.glsx.usedcar.web.AccountJwtProvider
;
import
com.glsx.usedcar.web.AccountJwtProvider
;
...
@@ -44,6 +45,8 @@ public class AccountController {
...
@@ -44,6 +45,8 @@ public class AccountController {
private
AuctionOrderService
auctionOrderService
;
private
AuctionOrderService
auctionOrderService
;
@Resource
@Resource
private
BidService
bidService
;
private
BidService
bidService
;
@Resource
private
PlatformContractService
platformContractService
;
/**
/**
* JWT认证服务
* JWT认证服务
*/
*/
...
@@ -95,6 +98,10 @@ public class AccountController {
...
@@ -95,6 +98,10 @@ public class AccountController {
Account
accountById
=
accountService
.
getAccountById
(
account
.
getAccountId
());
Account
accountById
=
accountService
.
getAccountById
(
account
.
getAccountId
());
AccountInfo
accountInfo
=
new
AccountInfo
(
accountById
);
AccountInfo
accountInfo
=
new
AccountInfo
(
accountById
);
accountInfo
.
setToken
(
jwtProvider
.
generateAccount
(
accountById
));
accountInfo
.
setToken
(
jwtProvider
.
generateAccount
(
accountById
));
// 设置签署截止时间(用于前端判断是否可以重新发起签署)
accountInfo
.
setSignDeadline
(
platformContractService
.
getSignDeadline
(
account
.
getAccountId
()));
return
accountInfo
;
return
accountInfo
;
}
}
...
...
aus-api/src/main/java/com/glsx/usedcar/web/api/account/PlatformContractController.java
0 → 100644
View file @
7dffb96
package
com
.
glsx
.
usedcar
.
web
.
api
.
account
;
import
com.glsx.usedcar.esign.exception.EsignDemoException
;
import
com.glsx.usedcar.module.account.entity.Account
;
import
com.glsx.usedcar.module.account.entity.PlatformContract
;
import
com.glsx.usedcar.module.account.service.AccountService
;
import
com.glsx.usedcar.module.account.service.PlatformContractService
;
import
com.glsx.usedcar.resp.BaseResp
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.bind.annotation.*
;
import
org.summerframework.core.exception.BusinessException
;
import
java.time.LocalDateTime
;
import
static
com
.
glsx
.
usedcar
.
web
.
WebConstants
.
LOGIN_ACCOUNT
;
/**
* 平台合同接口
* <p>
* 账户级平台交易整体合同,一次签署长期有效
* </p>
*
* @since 2026-08-05
*/
@Slf4j
@RestController
@RequestMapping
(
"/api/platformContract"
)
@RequiredArgsConstructor
@Tag
(
name
=
"平台合同接口"
,
description
=
"平台合同签署操作"
)
public
class
PlatformContractController
{
private
final
PlatformContractService
platformContractService
;
private
final
AccountService
accountService
;
/**
* 发起平台合同签署
* <p>
* 适用场景:
* 1. 审核通过后发起签署
* 2. 签署链接过期后重新发起
* </p>
* <p>
* 返回值说明:
* - 返回签署链接:需要用户点击链接完成签署
* - 返回"已签署平台合同":用户已完成签署,无需重复操作
* </p>
*
* @param account 登录账户
* @return 签署链接
*/
@PostMapping
(
"/initiateSigning"
)
@Operation
(
summary
=
"发起平台合同签署"
,
description
=
"发起平台合同签署,返回签署链接。如已签署则提示无需重复操作"
)
public
BaseResp
<
String
>
initiateSigning
(
@RequestAttribute
(
LOGIN_ACCOUNT
)
Account
account
)
{
int
accountId
=
account
.
getAccountId
();
log
.
info
(
"发起平台合同签署, accountId: {}"
,
accountId
);
// 检查是否已签署
if
(
platformContractService
.
hasSignedPlatformContract
(
accountId
))
{
log
.
info
(
"账户已签署平台合同,无需重复发起, accountId: {}"
,
accountId
);
return
BaseResp
.
success
(
"已签署平台合同"
);
}
// 检查是否有签署中且有效的合同
LocalDateTime
signDeadline
=
platformContractService
.
getSignDeadline
(
accountId
);
LocalDateTime
now
=
LocalDateTime
.
now
();
if
(
signDeadline
!=
null
&&
signDeadline
.
isAfter
(
now
))
{
log
.
info
(
"签署链接仍在有效期内, accountId: {}, signDeadline: {}"
,
accountId
,
signDeadline
);
throw
new
BusinessException
(
"签署链接仍在有效期内,请查收短信或稍后再试"
);
}
// 获取完整的账户信息
Account
fullAccount
=
accountService
.
getAccountById
(
accountId
);
// 检查认证状态
if
(
fullAccount
.
getCertifiedState
()
!=
Account
.
CertifiedState
.
CERTIFIED
)
{
log
.
warn
(
"账户未完成认证,无法发起签署, accountId: {}, certifiedState: {}"
,
accountId
,
fullAccount
.
getCertifiedState
());
throw
new
BusinessException
(
"请先完成认证后再签署平台合同"
);
}
try
{
// 构建平台合同
PlatformContract
contract
=
platformContractService
.
buildPlatformContractFile
(
fullAccount
);
if
(
contract
==
null
)
{
log
.
warn
(
"构建平台合同失败, accountId: {}"
,
accountId
);
throw
new
BusinessException
(
"构建平台合同失败,请稍后重试"
);
}
// 创建并发起签署
String
signUrl
=
platformContractService
.
createPlatformContract
(
contract
);
log
.
info
(
"平台合同签署流程创建成功, accountId: {}"
,
accountId
);
return
BaseResp
.
success
(
signUrl
);
}
catch
(
EsignDemoException
e
)
{
log
.
error
(
"e签宝签署失败, accountId: {}"
,
accountId
,
e
);
throw
new
BusinessException
(
"签署失败,请稍后重试"
);
}
catch
(
IllegalStateException
e
)
{
log
.
error
(
"平台合同签署异常, accountId: {}"
,
accountId
,
e
);
throw
new
BusinessException
(
e
.
getMessage
());
}
}
}
aus-api/src/main/java/com/glsx/usedcar/web/api/auction/AuctionOrderController.java
View file @
7dffb96
...
@@ -278,4 +278,24 @@ public class AuctionOrderController {
...
@@ -278,4 +278,24 @@ public class AuctionOrderController {
public
List
<
Contract
>
getContractsByOrderId
(
@RequestParam
int
orderId
)
{
public
List
<
Contract
>
getContractsByOrderId
(
@RequestParam
int
orderId
)
{
return
contractService
.
getContractsByOrderId
(
orderId
);
return
contractService
.
getContractsByOrderId
(
orderId
);
}
}
/**
* 确认提车(无交付合同签署依赖)
* <p>
* 简化后的确认提车流程:用户直接点击确认提车,无需签署交付合同
* 订单状态从待提车变为待过户
* </p>
*
* @param orderId 订单ID
* @param account 当前账户
* @return 更新后的订单
*/
@PostMapping
(
"confirmPickup"
)
public
AuctionOrder
confirmPickup
(
@RequestParam
int
orderId
,
@RequestAttribute
(
LOGIN_ACCOUNT
)
Account
account
)
{
try
{
return
auctionOrderService
.
confirmPickup
(
orderId
,
account
);
}
catch
(
FieldException
e
)
{
throw
new
RuntimeException
(
e
.
getMessage
(),
e
);
}
}
}
}
\ No newline at end of file
\ No newline at end of file
aus-api/src/main/java/com/glsx/usedcar/web/api/esign/ESignController.java
View file @
7dffb96
...
@@ -2,16 +2,12 @@ package com.glsx.usedcar.web.api.esign;
...
@@ -2,16 +2,12 @@ package com.glsx.usedcar.web.api.esign;
import
com.glsx.usedcar.esign.ESignService
;
import
com.glsx.usedcar.esign.ESignService
;
import
com.glsx.usedcar.esign.SignMissionComplete
;
import
com.glsx.usedcar.esign.SignMissionComplete
;
import
com.glsx.usedcar.esign.comm.EsignHttpResponse
;
import
com.glsx.usedcar.module.account.entity.PlatformContract
;
import
com.glsx.usedcar.module.account.service.PlatformContractService
;
import
com.glsx.usedcar.module.auction.entity.Contract
;
import
com.glsx.usedcar.module.auction.entity.Contract
;
import
com.glsx.usedcar.module.auction.service.ContractService
;
import
com.glsx.usedcar.module.auction.service.ContractService
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonObject
;
import
jakarta.annotation.Resource
;
import
jakarta.annotation.Resource
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
@@ -26,6 +22,8 @@ public class ESignController {
...
@@ -26,6 +22,8 @@ public class ESignController {
private
ContractService
contractService
;
private
ContractService
contractService
;
@Resource
@Resource
private
ESignService
eSignService
;
private
ESignService
eSignService
;
@Resource
private
PlatformContractService
platformContractService
;
/**
/**
...
@@ -47,9 +45,24 @@ public class ESignController {
...
@@ -47,9 +45,24 @@ public class ESignController {
// 流程结束通知
// 流程结束通知
if
(
"2"
.
equals
(
signMissionComplete
.
getSignFlowStatus
()))
{
if
(
"2"
.
equals
(
signMissionComplete
.
getSignFlowStatus
()))
{
String
signFlowId
=
signMissionComplete
.
getSignFlowId
();
String
signFlowId
=
signMissionComplete
.
getSignFlowId
();
// 先尝试处理拍卖/交付合同
Contract
contract
=
contractService
.
signContract
(
signFlowId
);
Contract
contract
=
contractService
.
signContract
(
signFlowId
);
// 下载合同文件
if
(
contract
!=
null
)
{
eSignService
.
downloadContractFile
(
contract
);
// 下载合同文件
eSignService
.
downloadContractFile
(
contract
);
log
.
info
(
"拍卖/交付合同签署完成, signFlowId: {}, contractId: {}"
,
signFlowId
,
contract
.
getContractId
());
}
else
{
// 尝试处理平台合同
PlatformContract
platformContract
=
platformContractService
.
signPlatformContract
(
signFlowId
);
if
(
platformContract
!=
null
)
{
log
.
info
(
"平台合同签署完成, signFlowId: {}, accountId: {}"
,
signFlowId
,
platformContract
.
getAccount
().
getAccountId
());
}
else
{
log
.
warn
(
"未找到对应的签署流程, signFlowId: {}"
,
signFlowId
);
}
}
}
}
break
;
break
;
default
:
default
:
...
...
aus-core/src/main/java/com/glsx/usedcar/converts/PlatformContractConverter.java
0 → 100644
View file @
7dffb96
package
com
.
glsx
.
usedcar
.
converts
;
import
com.glsx.usedcar.module.account.entity.PlatformContract
;
import
com.glsx.usedcar.module.account.vo.PlatformContractPageRespVO
;
import
com.glsx.usedcar.module.account.vo.PlatformContractRespVO
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.Mapping
;
import
java.util.List
;
/**
* 平台合同实体转换器
*
* @author yangwei
* @since 2026-08-04
*/
@Mapper
(
componentModel
=
"spring"
)
public
interface
PlatformContractConverter
{
/**
* 单个实体转换为详情VO
*
* @param contract 平台合同实体
* @return 平台合同详情响应VO
*/
@Mapping
(
target
=
"accountId"
,
source
=
"account.accountId"
)
@Mapping
(
target
=
"accountName"
,
source
=
"account.accountName"
)
@Mapping
(
target
=
"accountMobile"
,
source
=
"account.mobile"
)
@Mapping
(
target
=
"contractStatusDesc"
,
expression
=
"java(getContractStatusDesc(contract.getContractStatus()))"
)
PlatformContractRespVO
toRespVO
(
PlatformContract
contract
);
/**
* 单个实体转换为分页列表VO
*
* @param contract 平台合同实体
* @return 平台合同分页响应VO
*/
@Mapping
(
target
=
"accountId"
,
source
=
"account.accountId"
)
@Mapping
(
target
=
"accountName"
,
source
=
"account.accountName"
)
@Mapping
(
target
=
"accountMobile"
,
source
=
"account.mobile"
)
@Mapping
(
target
=
"contractStatusDesc"
,
expression
=
"java(getContractStatusDesc(contract.getContractStatus()))"
)
PlatformContractPageRespVO
toPageRespVO
(
PlatformContract
contract
);
/**
* 多个实体转换为VO列表
*
* @param contracts 平台合同实体列表
* @return 平台合同响应VO列表
*/
List
<
PlatformContractRespVO
>
toRespVOList
(
List
<
PlatformContract
>
contracts
);
/**
* 获取合同状态描述
*/
default
String
getContractStatusDesc
(
PlatformContract
.
ContractStatus
status
)
{
if
(
status
==
null
)
{
return
null
;
}
return
switch
(
status
)
{
case
PENDING
->
"待签署"
;
case
SIGNING
->
"签署中"
;
case
SIGNED
->
"已签署"
;
case
EXPIRED
->
"已过期"
;
case
CANCELLED
->
"已作废"
;
};
}
}
aus-core/src/main/java/com/glsx/usedcar/esign/DocTemplateRequest.java
View file @
7dffb96
package
com
.
glsx
.
usedcar
.
esign
;
package
com
.
glsx
.
usedcar
.
esign
;
import
com.glsx.usedcar.module.account.entity.Account
;
import
com.glsx.usedcar.module.auction.entity.AuctionOrder
;
import
com.glsx.usedcar.module.auction.entity.AuctionOrder
;
import
com.glsx.usedcar.module.auction.entity.Contract
;
import
com.glsx.usedcar.module.auction.entity.Contract
;
import
com.glsx.usedcar.module.coupon.entity.CouponOrderUsage
;
import
com.glsx.usedcar.module.coupon.entity.CouponOrderUsage
;
...
@@ -168,6 +169,29 @@ public record DocTemplateRequest(String docTemplateId, String fileName, List<Com
...
@@ -168,6 +169,29 @@ public record DocTemplateRequest(String docTemplateId, String fileName, List<Com
return
new
DocTemplateRequest
(
docTemplateId
,
fileName
,
components
);
return
new
DocTemplateRequest
(
docTemplateId
,
fileName
,
components
);
}
}
/**
* 构建平台合同模板请求
*
* @param docTemplateId e签宝模板ID
* @param account 签约账户
* @param platformSignCompanyName 平台方签约公司名称
* @return 平台合同模板请求
*/
public
static
DocTemplateRequest
ofPlatform
(
String
docTemplateId
,
Account
account
,
String
platformSignCompanyName
)
{
String
fileName
=
account
.
getAccountName
()
+
"_平台交易整体合同"
;
List
<
Component
>
components
=
new
ArrayList
<>();
// 平台方信息(甲方)
components
.
add
(
new
Component
(
"platformSignCompanyName"
,
platformSignCompanyName
));
// signDate 由签名区域的 SignDateConfig 自动填充,无需预先填入
// 客户信息(乙方)
components
.
add
(
new
Component
(
"signCustomerName"
,
fillBlank
(
account
.
getAccountName
())));
// customerSignDate 由签名区域的 SignDateConfig 自动填充,无需预先填入
return
new
DocTemplateRequest
(
docTemplateId
,
fileName
,
components
);
}
private
static
String
fillBlank
(
String
str
)
{
private
static
String
fillBlank
(
String
str
)
{
if
(
str
==
null
||
str
.
trim
().
isEmpty
())
{
if
(
str
==
null
||
str
.
trim
().
isEmpty
())
{
return
""
;
return
""
;
...
...
aus-core/src/main/java/com/glsx/usedcar/gsc/ReceiveClient.java
0 → 100644
View file @
7dffb96
package
com
.
glsx
.
usedcar
.
gsc
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
jakarta.annotation.Resource
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.codec.digest.HmacAlgorithms
;
import
org.apache.commons.codec.digest.HmacUtils
;
import
org.apache.commons.lang3.RandomStringUtils
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.MediaType
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.client.RestTemplate
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* 收车端接口调用客户端
* <p>
* 用于从收车端同步过户资料(electronicContractField)数据
* </p>
*/
@Slf4j
@Component
public
class
ReceiveClient
{
@Value
(
"${gsc.url}"
)
private
String
gscUrl
;
@Value
(
"${gsc.secret}"
)
private
String
secret
;
private
static
final
ObjectMapper
objectMapper
=
new
ObjectMapper
();
@Resource
private
RestTemplate
restTemplate
;
/**
* 批量查询车辆过户资料
* <p>
* 调用收车端接口: POST /auction/electronicContractField/batch
* </p>
*
* @param sourceNos 车源号列表(评估单编号)
* @return 过户资料Map (sourceNo -> electronicContractField JSON)
*/
public
Map
<
String
,
String
>
batchQueryElectronicContractField
(
List
<
String
>
sourceNos
)
{
if
(
sourceNos
==
null
||
sourceNos
.
isEmpty
())
{
return
new
HashMap
<>();
}
String
url
=
gscUrl
+
"/auction/electronicContractField/batch"
;
try
{
// 构建请求头(使用与 GscInvoker 相同的签名逻辑)
HttpHeaders
headers
=
buildHeaders
(
sourceNos
);
HttpEntity
<
List
<
String
>>
requestEntity
=
new
HttpEntity
<>(
sourceNos
,
headers
);
@SuppressWarnings
(
"unchecked"
)
ResponseResult
response
=
restTemplate
.
postForObject
(
url
,
requestEntity
,
ResponseResult
.
class
);
if
(
response
!=
null
&&
response
.
isSuccess
())
{
log
.
info
(
"批量查询过户资料成功,sourceNos数量: {}"
,
sourceNos
.
size
());
@SuppressWarnings
(
"unchecked"
)
Map
<
String
,
String
>
data
=
(
Map
<
String
,
String
>)
response
.
getData
();
return
data
!=
null
?
data
:
new
HashMap
<>();
}
else
{
log
.
warn
(
"批量查询过户资料失败: {}"
,
response
!=
null
?
response
.
getMsg
()
:
"响应为空"
);
return
new
HashMap
<>();
}
}
catch
(
Exception
e
)
{
log
.
error
(
"批量查询过户资料异常,sourceNos: {}"
,
sourceNos
,
e
);
return
new
HashMap
<>();
}
}
/**
* 查询单个车辆过户资料
* <p>
* 调用收车端接口: GET /auction/electronicContractField?sourceNo={sourceNo}
* </p>
*
* @param sourceNo 车源号(评估单编号)
* @return electronicContractField JSON字符串
*/
public
String
queryElectronicContractField
(
String
sourceNo
)
{
if
(
sourceNo
==
null
||
sourceNo
.
isEmpty
())
{
return
null
;
}
String
url
=
gscUrl
+
"/auction/electronicContractField?sourceNo="
+
sourceNo
;
try
{
HttpHeaders
headers
=
buildHeaders
(
sourceNo
);
HttpEntity
<
Void
>
requestEntity
=
new
HttpEntity
<>(
headers
);
@SuppressWarnings
(
"unchecked"
)
ResponseResult
response
=
restTemplate
.
getForObject
(
url
,
ResponseResult
.
class
);
if
(
response
!=
null
&&
response
.
isSuccess
())
{
log
.
info
(
"查询过户资料成功,sourceNo: {}"
,
sourceNo
);
return
response
.
getData
()
!=
null
?
response
.
getData
().
toString
()
:
null
;
}
else
{
log
.
warn
(
"查询过户资料失败, sourceNo: {}, 原因: {}"
,
sourceNo
,
response
!=
null
?
response
.
getMsg
()
:
"响应为空"
);
return
null
;
}
}
catch
(
Exception
e
)
{
log
.
error
(
"查询过户资料异常,sourceNo: {}"
,
sourceNo
,
e
);
return
null
;
}
}
/**
* 异步批量查询车辆过户资料
*
* @param sourceNos 车源号列表
* @param callback 回调函数,接收查询结果
*/
@Async
public
void
batchQueryElectronicContractFieldAsync
(
List
<
String
>
sourceNos
,
java
.
util
.
function
.
Consumer
<
Map
<
String
,
String
>>
callback
)
{
Map
<
String
,
String
>
result
=
batchQueryElectronicContractField
(
sourceNos
);
if
(
callback
!=
null
)
{
callback
.
accept
(
result
);
}
}
/**
* 构建带签名的请求头(参考 GscInvoker 的签名逻辑)
*/
private
HttpHeaders
buildHeaders
(
Object
requestData
)
{
String
currentTimeMillis
=
String
.
valueOf
(
System
.
currentTimeMillis
());
String
randomNumeric
=
RandomStringUtils
.
randomNumeric
(
6
);
// 构建签名参数
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"X-App-Id"
,
"auction_platform"
);
params
.
put
(
"X-Timestamp"
,
currentTimeMillis
);
params
.
put
(
"X-Nonce"
,
randomNumeric
);
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
set
(
"X-App-Id"
,
"auction_platform"
);
headers
.
set
(
"X-Sign"
,
generateSign
(
params
));
headers
.
set
(
"X-Timestamp"
,
currentTimeMillis
);
headers
.
set
(
"X-Nonce"
,
randomNumeric
);
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON
);
return
headers
;
}
/**
* 生成签名(参考 GscInvoker 的签名逻辑)
*/
private
String
generateSign
(
Map
<
String
,
Object
>
params
)
{
// 1. 参数排序
List
<
String
>
keys
=
new
java
.
util
.
ArrayList
<>(
params
.
keySet
());
java
.
util
.
Collections
.
sort
(
keys
);
// 2. 拼接参数
StringBuilder
sb
=
new
StringBuilder
();
for
(
String
key
:
keys
)
{
if
(
"X-Sign"
.
equals
(
key
)
||
params
.
get
(
key
)
==
null
||
""
.
equals
(
params
.
get
(
key
)))
{
continue
;
}
sb
.
append
(
key
).
append
(
"="
).
append
(
params
.
get
(
key
)).
append
(
"&"
);
}
String
stringToSign
=
sb
.
toString
();
stringToSign
=
stringToSign
+
"secret="
+
secret
;
// 3. 计算HMAC-SHA256签名
return
new
HmacUtils
(
HmacAlgorithms
.
HMAC_SHA_256
,
secret
).
hmacHex
(
stringToSign
);
}
}
aus-core/src/main/java/com/glsx/usedcar/module/account/dao/PlatformContractDao.java
0 → 100644
View file @
7dffb96
package
com
.
glsx
.
usedcar
.
module
.
account
.
dao
;
import
com.glsx.usedcar.module.account.entity.Account
;
import
com.glsx.usedcar.module.account.entity.PlatformContract
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.summerframework.orm.BaseRepository
;
import
java.util.List
;
/**
* 平台合同(PlatformContract)表数据库访问层
*
* @since 2026-07-31
*/
public
interface
PlatformContractDao
extends
BaseRepository
<
PlatformContract
,
Integer
>,
JpaSpecificationExecutor
<
PlatformContract
>
{
/**
* 根据签署流程ID查询平台合同
*/
PlatformContract
findTopBySignFlowId
(
String
signFlowId
);
/**
* 根据合同编号查询平台合同
*/
PlatformContract
findByContractCode
(
String
contractCode
);
/**
* 根据账户查询平台合同列表
*/
List
<
PlatformContract
>
findByAccount_AccountIdOrderByCreateTimeDesc
(
int
accountId
);
/**
* 根据账户查询已签署的平台合同
*/
PlatformContract
findTopByAccount_AccountIdAndContractStatusOrderByCreateTimeDesc
(
int
accountId
,
PlatformContract
.
ContractStatus
contractStatus
);
/**
* 检查账户是否已签署平台合同
*/
boolean
existsByAccount_AccountIdAndContractStatus
(
int
accountId
,
PlatformContract
.
ContractStatus
contractStatus
);
}
aus-core/src/main/java/com/glsx/usedcar/module/account/domain/AccountInfo.java
View file @
7dffb96
...
@@ -6,6 +6,8 @@ import lombok.NoArgsConstructor;
...
@@ -6,6 +6,8 @@ import lombok.NoArgsConstructor;
import
lombok.Setter
;
import
lombok.Setter
;
import
org.summerframework.storage.domain.FileInfo
;
import
org.summerframework.storage.domain.FileInfo
;
import
java.time.LocalDateTime
;
@Getter
@Getter
@Setter
@Setter
@NoArgsConstructor
@NoArgsConstructor
...
@@ -43,6 +45,27 @@ public class AccountInfo {
...
@@ -43,6 +45,27 @@ public class AccountInfo {
*/
*/
private
boolean
supper
;
private
boolean
supper
;
/**
* 是否已签署平台合同
*/
private
boolean
platformContractSigned
;
/**
* 平台合同签署时间(已签署时才有值)
*/
private
LocalDateTime
platformContractSignTime
;
/**
* 当前签署中合同的签署截止时间
* <p>
* 用于前端判断是否可以重新发起签署:
* - null:没有签署中的合同,可以发起新的
* - 大于当前时间:签署链接还有效,不需要重新发起
* - 小于等于当前时间:已过期,可以重新发起
* </p>
*/
private
LocalDateTime
signDeadline
;
public
AccountInfo
(
Account
account
)
{
public
AccountInfo
(
Account
account
)
{
setAccountInfo
(
account
);
setAccountInfo
(
account
);
}
}
...
@@ -59,6 +82,8 @@ public class AccountInfo {
...
@@ -59,6 +82,8 @@ public class AccountInfo {
this
.
openId
=
account
.
getOpenId
();
this
.
openId
=
account
.
getOpenId
();
this
.
surplus
=
account
.
getSurplus
();
this
.
surplus
=
account
.
getSurplus
();
this
.
supper
=
account
.
isSupper
();
this
.
supper
=
account
.
isSupper
();
this
.
idCard
=
account
.
getIdCard
();
this
.
idCard
=
account
.
getIdCard
();
this
.
platformContractSigned
=
account
.
isPlatformContractSigned
();
this
.
platformContractSignTime
=
account
.
getPlatformContractSignTime
();
}
}
}
}
aus-core/src/main/java/com/glsx/usedcar/module/account/entity/Account.java
View file @
7dffb96
...
@@ -225,6 +225,18 @@ public class Account extends AuditingTimeEntity implements Serializable {
...
@@ -225,6 +225,18 @@ public class Account extends AuditingTimeEntity implements Serializable {
private
String
disableReason
;
private
String
disableReason
;
/**
/**
* 是否已签署平台合同
*/
@Column
(
nullable
=
false
)
private
boolean
platformContractSigned
=
false
;
/**
* 平台合同签署时间
*/
@Column
private
LocalDateTime
platformContractSignTime
;
/**
* account_groups
* account_groups
*/
*/
@ManyToMany
(
targetEntity
=
AccountTag
.
class
,
cascade
=
{
CascadeType
.
MERGE
,
CascadeType
.
PERSIST
},
fetch
=
FetchType
.
LAZY
)
@ManyToMany
(
targetEntity
=
AccountTag
.
class
,
cascade
=
{
CascadeType
.
MERGE
,
CascadeType
.
PERSIST
},
fetch
=
FetchType
.
LAZY
)
...
@@ -263,6 +275,12 @@ public class Account extends AuditingTimeEntity implements Serializable {
...
@@ -263,6 +275,12 @@ public class Account extends AuditingTimeEntity implements Serializable {
private
Set
<
Withdraw
>
withdraws
=
new
HashSet
<>(
0
);
private
Set
<
Withdraw
>
withdraws
=
new
HashSet
<>(
0
);
/**
/**
* platform_contract
*/
@OneToMany
(
cascade
=
{},
fetch
=
FetchType
.
LAZY
,
mappedBy
=
"account"
)
private
Set
<
PlatformContract
>
platformContracts
=
new
HashSet
<>(
0
);
/**
* 累计成交数量
* 累计成交数量
*/
*/
@Transient
@Transient
...
...
aus-core/src/main/java/com/glsx/usedcar/module/account/entity/PlatformContract.java
0 → 100644
View file @
7dffb96
package
com
.
glsx
.
usedcar
.
module
.
account
.
entity
;
import
jakarta.persistence.*
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
org.hibernate.annotations.DynamicInsert
;
import
org.hibernate.annotations.DynamicUpdate
;
import
org.springframework.data.jpa.domain.support.AuditingEntityListener
;
import
org.summerframework.orm.entity.AuditingTimeEntity
;
import
org.summerframework.storage.converter.FileInfosConverter
;
import
org.summerframework.storage.domain.FileInfo
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
import
java.util.List
;
import
static
jakarta
.
persistence
.
GenerationType
.
IDENTITY
;
/**
* 平台合同(PlatformContract)实体类
* <p>
* 账户级平台交易整体合同,一次签署长期有效,独立于拍卖订单
* </p>
*/
@Entity
@DynamicInsert
@DynamicUpdate
@Table
@EntityListeners
(
AuditingEntityListener
.
class
)
@Getter
@Setter
@NoArgsConstructor
public
class
PlatformContract
extends
AuditingTimeEntity
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
1L
;
/**
* 主键ID
*/
@Id
@GeneratedValue
(
strategy
=
IDENTITY
)
@Column
(
unique
=
true
,
nullable
=
false
)
private
int
platformContractId
;
/**
* 关联账户
*/
@ManyToOne
(
cascade
=
{},
fetch
=
FetchType
.
LAZY
)
@JoinColumns
({
@JoinColumn
(
name
=
"ACCOUNT_ID"
,
nullable
=
false
)})
private
Account
account
;
/**
* 合同编号
*/
@Column
(
nullable
=
false
,
length
=
64
,
unique
=
true
)
private
String
contractCode
;
/**
* 合同名称
*/
@Column
(
nullable
=
false
,
length
=
128
)
private
String
contractName
;
/**
* 签署人姓名
*/
@Column
(
nullable
=
false
,
length
=
128
)
private
String
signerName
;
/**
* 签署人手机号
*/
@Column
(
nullable
=
false
,
length
=
16
)
private
String
signerMobile
;
/**
* 签署人身份证
*/
@Column
(
length
=
32
)
private
String
signerIdCard
;
/**
* 合同状态
*/
@Enumerated
(
EnumType
.
STRING
)
@Column
(
nullable
=
false
,
length
=
32
)
private
ContractStatus
contractStatus
=
ContractStatus
.
PENDING
;
/**
* 合同内容
*/
@Column
(
columnDefinition
=
"TEXT"
)
private
String
contractContent
;
/**
* 合同附件
*/
@Convert
(
converter
=
FileInfosConverter
.
class
)
@Column
private
List
<
FileInfo
>
contractFiles
;
/**
* e签宝文件ID
*/
@Column
(
length
=
64
)
private
String
fileId
;
/**
* 合同签署流程ID
*/
@Column
(
length
=
64
)
private
String
signFlowId
;
/**
* 签署时间
*/
@Column
private
LocalDateTime
signTime
;
/**
* 签署截止时间(超时后需重新发起)
*/
@Column
private
LocalDateTime
signDeadline
;
/**
* 合同附件路径(本地临时文件路径)
*/
@Column
private
String
filePath
;
/**
* 合同状态枚举
*/
public
enum
ContractStatus
{
/**
* 待签署
*/
PENDING
,
/**
* 签署中
*/
SIGNING
,
/**
* 已签署
*/
SIGNED
,
/**
* 已过期(未在规定时间内签署)
*/
EXPIRED
,
/**
* 已作废
*/
CANCELLED
;
}
/**
* 创建平台合同
*/
public
PlatformContract
(
Account
account
,
String
contractCode
,
String
contractName
,
String
signerName
,
String
signerMobile
,
String
signerIdCard
)
{
this
.
account
=
account
;
this
.
contractCode
=
contractCode
;
this
.
contractName
=
contractName
;
this
.
signerName
=
signerName
;
this
.
signerMobile
=
signerMobile
;
this
.
signerIdCard
=
signerIdCard
;
this
.
contractStatus
=
ContractStatus
.
PENDING
;
}
}
aus-core/src/main/java/com/glsx/usedcar/module/account/service/AccountService.java
View file @
7dffb96
...
@@ -18,6 +18,7 @@ import com.glsx.usedcar.module.meta.AuditState;
...
@@ -18,6 +18,7 @@ import com.glsx.usedcar.module.meta.AuditState;
import
com.glsx.usedcar.module.track.dao.ApproveHistoryDao
;
import
com.glsx.usedcar.module.track.dao.ApproveHistoryDao
;
import
com.glsx.usedcar.module.track.entity.ApproveHistory
;
import
com.glsx.usedcar.module.track.entity.ApproveHistory
;
import
jakarta.annotation.Resource
;
import
jakarta.annotation.Resource
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.RandomStringUtils
;
import
org.apache.commons.lang3.RandomStringUtils
;
import
org.hibernate.ObjectNotFoundException
;
import
org.hibernate.ObjectNotFoundException
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
...
@@ -32,14 +33,20 @@ import org.summerframework.core.exception.FieldException;
...
@@ -32,14 +33,20 @@ import org.summerframework.core.exception.FieldException;
import
org.summerframework.orm.UpdateField
;
import
org.summerframework.orm.UpdateField
;
import
org.summerframework.orm.paging.Pagination
;
import
org.summerframework.orm.paging.Pagination
;
import
java.time.*
;
import
java.time.LocalDate
;
import
java.util.*
;
import
java.time.LocalDateTime
;
import
java.time.LocalTime
;
import
java.time.ZoneId
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Optional
;
/**
/**
* 个人账户(Account) 服务实现类
* 个人账户(Account) 服务实现类
*
*
* @since 2025-10-13 12:18:11
* @since 2025-10-13 12:18:11
*/
*/
@Slf4j
@Service
@Service
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
)
public
class
AccountService
extends
AbstractAuctionService
{
public
class
AccountService
extends
AbstractAuctionService
{
...
@@ -62,6 +69,9 @@ public class AccountService extends AbstractAuctionService {
...
@@ -62,6 +69,9 @@ public class AccountService extends AbstractAuctionService {
@Resource
@Resource
private
BidDao
bidDao
;
private
BidDao
bidDao
;
@Resource
private
PlatformContractService
platformContractService
;
/**
/**
* 通过ID查询一个个人账户
* 通过ID查询一个个人账户
*
*
...
@@ -293,12 +303,40 @@ public class AccountService extends AbstractAuctionService {
...
@@ -293,12 +303,40 @@ public class AccountService extends AbstractAuctionService {
}
else
if
(
account
.
getAccountType
()
==
Account
.
AccountType
.
PERSON
)
{
}
else
if
(
account
.
getAccountType
()
==
Account
.
AccountType
.
PERSON
)
{
account
.
setAccountType
(
Account
.
AccountType
.
COMPANY
);
account
.
setAccountType
(
Account
.
AccountType
.
COMPANY
);
}
}
// 审核通过后触发平台合同签署
triggerPlatformContractSigning
(
account
);
}
else
{
}
else
{
account
.
setCertifiedState
(
Account
.
CertifiedState
.
CERTIFY_FAILED
);
account
.
setCertifiedState
(
Account
.
CertifiedState
.
CERTIFY_FAILED
);
}
}
return
approveHistoryDao
.
save
(
approveHistory
);
return
approveHistoryDao
.
save
(
approveHistory
);
}
}
/**
* 触发平台合同签署
* 审核通过后为账户创建平台合同并发起签署流程
*
* @param account 账户
*/
private
void
triggerPlatformContractSigning
(
Account
account
)
{
try
{
// 检查是否已签署平台合同
if
(!
platformContractService
.
hasSignedPlatformContract
(
account
.
getAccountId
()))
{
// 构建平台合同
PlatformContract
contract
=
platformContractService
.
buildPlatformContractFile
(
account
);
if
(
contract
!=
null
)
{
// 创建并保存合同,触发e签宝签署流程(e签宝会自动发送短信给用户)
platformContractService
.
createPlatformContract
(
contract
);
log
.
info
(
"平台合同签署流程已创建, accountId: {}"
,
account
.
getAccountId
());
}
}
}
catch
(
Exception
e
)
{
// 平台合同签署失败不影响认证流程,记录日志即可
// 用户可以稍后手动触发签署
log
.
error
(
"触发平台合同签署失败, accountId: {}"
,
account
.
getAccountId
(),
e
);
}
}
/**
/**
* 更改用户wechat
* 更改用户wechat
...
...
aus-core/src/main/java/com/glsx/usedcar/module/account/service/PlatformContractService.java
0 → 100644
View file @
7dffb96
package
com
.
glsx
.
usedcar
.
module
.
account
.
service
;
import
com.glsx.usedcar.converts.PlatformContractConverter
;
import
com.glsx.usedcar.esign.DocTemplateRequest
;
import
com.glsx.usedcar.esign.ESignService
;
import
com.glsx.usedcar.esign.SignFlowConfig
;
import
com.glsx.usedcar.esign.comm.EsignHttpResponse
;
import
com.glsx.usedcar.esign.exception.EsignDemoException
;
import
com.glsx.usedcar.module.account.dao.PlatformContractDao
;
import
com.glsx.usedcar.module.account.entity.Account
;
import
com.glsx.usedcar.module.account.entity.PlatformContract
;
import
com.glsx.usedcar.module.account.vo.PlatformContractPageRespVO
;
import
com.glsx.usedcar.module.account.vo.PlatformContractRespVO
;
import
com.glsx.usedcar.module.auction.dao.ContractTemplateDao
;
import
com.glsx.usedcar.module.auction.entity.ContractTemplate
;
import
com.glsx.usedcar.util.CoderGenerator
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
jakarta.annotation.Resource
;
import
lombok.extern.slf4j.Slf4j
;
import
org.hibernate.ObjectNotFoundException
;
import
org.springframework.data.domain.Page
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.summerframework.orm.paging.Pagination
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Objects
;
/**
* 平台合同(PlatformContract) 服务实现类
* <p>
* 账户级平台交易整体合同管理,一次签署长期有效
* </p>
*
* @since 2026-07-31
*/
@Slf4j
@Service
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
)
public
class
PlatformContractService
{
@Resource
private
PlatformContractDao
platformContractDao
;
@Resource
private
ContractTemplateDao
contractTemplateDao
;
@Resource
private
ESignService
eSignService
;
@Resource
private
PlatformContractConverter
platformContractConverter
;
/**
* 通过ID查询平台合同
*
* @param platformContractId 主键
* @return 实例对象
*/
public
PlatformContract
getPlatformContractById
(
int
platformContractId
)
{
return
platformContractDao
.
findById
(
platformContractId
)
.
orElseThrow
(()
->
new
ObjectNotFoundException
(
platformContractId
,
PlatformContract
.
class
.
getSimpleName
()));
}
/**
* 分页查询平台合同
*
* @param pagination 分页参数
* @return 平台合同列表
*/
public
Page
<
PlatformContract
>
pagePlatformContract
(
Pagination
<
PlatformContract
>
pagination
)
{
return
platformContractDao
.
findAll
(
pagination
,
pagination
.
getPageRequest
());
}
/**
* 分页查询平台合同(返回VO)
*
* @param pagination 分页参数
* @return 平台合同VO分页列表
*/
public
Page
<
PlatformContractPageRespVO
>
pagePlatformContractVO
(
Pagination
<
PlatformContract
>
pagination
)
{
Page
<
PlatformContract
>
result
=
platformContractDao
.
findAll
(
pagination
,
pagination
.
getPageRequest
());
return
result
.
map
(
platformContractConverter:
:
toPageRespVO
);
}
/**
* 根据ID查询平台合同详情(返回VO)
*
* @param platformContractId 主键
* @return 平台合同详情VO
*/
public
PlatformContractRespVO
getPlatformContractVOById
(
int
platformContractId
)
{
PlatformContract
contract
=
platformContractDao
.
findById
(
platformContractId
)
.
orElseThrow
(()
->
new
ObjectNotFoundException
(
platformContractId
,
PlatformContract
.
class
.
getSimpleName
()));
return
platformContractConverter
.
toRespVO
(
contract
);
}
/**
* 根据账户查询平台合同列表(返回VO)
*
* @param accountId 账户ID
* @return 平台合同VO列表
*/
public
List
<
PlatformContractRespVO
>
getPlatformContractVOsByAccountId
(
int
accountId
)
{
List
<
PlatformContract
>
contracts
=
platformContractDao
.
findByAccount_AccountIdOrderByCreateTimeDesc
(
accountId
);
return
platformContractConverter
.
toRespVOList
(
contracts
);
}
/**
* 根据账户查询平台合同列表
*
* @param accountId 账户ID
* @return 平台合同列表
*/
public
List
<
PlatformContract
>
getPlatformContractsByAccountId
(
int
accountId
)
{
return
platformContractDao
.
findByAccount_AccountIdOrderByCreateTimeDesc
(
accountId
);
}
/**
* 检查账户是否已签署平台合同
*
* @param accountId 账户ID
* @return 是否已签署
*/
public
boolean
hasSignedPlatformContract
(
int
accountId
)
{
return
platformContractDao
.
existsByAccount_AccountIdAndContractStatus
(
accountId
,
PlatformContract
.
ContractStatus
.
SIGNED
);
}
/**
* 获取账户当前签署中合同的签署截止时间
* <p>
* 用于判断是否可以重新发起签署:
* - 返回 null:没有签署中的合同,可以发起新的
* - 返回时间 > 当前时间:签署链接还有效,不需要重新发起
* - 返回时间 <= 当前时间:已过期,可以重新发起
* </p>
*
* @param accountId 账户ID
* @return 签署截止时间,如果没有签署中的合同则返回 null
*/
public
LocalDateTime
getSignDeadline
(
int
accountId
)
{
PlatformContract
contract
=
platformContractDao
.
findTopByAccount_AccountIdAndContractStatusOrderByCreateTimeDesc
(
accountId
,
PlatformContract
.
ContractStatus
.
SIGNING
);
return
contract
!=
null
?
contract
.
getSignDeadline
()
:
null
;
}
/**
* 构建平台合同文件
*
* @param account 账户
* @return 平台合同实体(未保存)
*/
public
PlatformContract
buildPlatformContractFile
(
Account
account
)
{
// 检查是否已签署
if
(
hasSignedPlatformContract
(
account
.
getAccountId
()))
{
log
.
info
(
"账户 {} 已签署平台合同,无需重复创建"
,
account
.
getAccountId
());
return
platformContractDao
.
findTopByAccount_AccountIdAndContractStatusOrderByCreateTimeDesc
(
account
.
getAccountId
(),
PlatformContract
.
ContractStatus
.
SIGNED
);
}
// 获取平台合同模板
ContractTemplate
template
=
contractTemplateDao
.
findTopByEnabledIsTrueAndTemplateTypeOrderByVersionCodeDesc
(
ContractTemplate
.
TemplateType
.
PLATFORM
);
if
(
Objects
.
isNull
(
template
))
{
log
.
warn
(
"未找到启用的平台合同模板"
);
throw
new
IllegalStateException
(
"未找到启用的平台合同模板,请先配置"
);
}
// 创建合同实体
String
contractName
=
account
.
getAccountName
()
+
"_平台交易整体合同"
;
PlatformContract
contract
=
new
PlatformContract
(
account
,
CoderGenerator
.
generateCode
(
4
),
contractName
,
account
.
getAccountName
(),
account
.
getMobile
(),
account
.
getIdCard
()
);
contract
.
setContractContent
(
template
.
getTemplateContent
());
contract
.
setContractStatus
(
PlatformContract
.
ContractStatus
.
PENDING
);
return
contract
;
}
/**
* 创建平台合同并发起签署
*
* @param platformContract 平台合同实例对象
* @return 签署链接
*/
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
public
String
createPlatformContract
(
PlatformContract
platformContract
)
throws
EsignDemoException
{
platformContract
.
setContractStatus
(
PlatformContract
.
ContractStatus
.
SIGNING
);
platformContract
.
setSignDeadline
(
LocalDateTime
.
now
().
plusHours
(
24
));
// 获取平台合同模板
ContractTemplate
template
=
contractTemplateDao
.
findTopByEnabledIsTrueAndTemplateTypeOrderByVersionCodeDesc
(
ContractTemplate
.
TemplateType
.
PLATFORM
);
if
(
Objects
.
isNull
(
template
))
{
log
.
warn
(
"未找到启用的平台合同模板"
);
throw
new
IllegalStateException
(
"未找到启用的平台合同模板,请先配置"
);
}
// 从数据库获取模板ID和平台方名称
String
docTemplateId
=
template
.
getEsignId
();
String
platformSignCompanyName
=
template
.
getPlatformSignCompanyName
();
if
(
docTemplateId
==
null
||
docTemplateId
.
isEmpty
())
{
throw
new
IllegalStateException
(
"平台合同模板未配置e签宝模板ID"
);
}
if
(
platformSignCompanyName
==
null
||
platformSignCompanyName
.
isEmpty
())
{
platformSignCompanyName
=
"深圳市优加智汇科技有限公司"
;
}
// 构建平台合同模板请求
Account
account
=
platformContract
.
getAccount
();
DocTemplateRequest
request
=
DocTemplateRequest
.
ofPlatform
(
docTemplateId
,
account
,
platformSignCompanyName
);
// 调用e签宝API创建合同文件
Gson
gson
=
new
Gson
();
EsignHttpResponse
createByDocTemplate
=
eSignService
.
createByDocTemplate
(
gson
.
toJson
(
request
));
JsonObject
createByDocTemplateObject
=
gson
.
fromJson
(
createByDocTemplate
.
getBody
(),
JsonObject
.
class
);
String
fileId
=
createByDocTemplateObject
.
getAsJsonObject
(
"data"
).
get
(
"fileId"
).
getAsString
();
platformContract
.
setFileId
(
fileId
);
// 获取模板组件信息用于签署位置
EsignHttpResponse
componentsInfo
=
eSignService
.
getComponentsInfo
(
docTemplateId
);
JsonObject
componentsInfoObject
=
gson
.
fromJson
(
componentsInfo
.
getBody
(),
JsonObject
.
class
);
JsonObject
data
=
componentsInfoObject
.
getAsJsonObject
(
"data"
);
JsonArray
components
=
data
.
getAsJsonArray
(
"components"
);
// 构建签署流程
SignFlowConfig
signData
=
buildPlatformContractSignFlow
(
platformContract
,
fileId
,
components
);
String
json
=
gson
.
toJson
(
signData
);
// 创建合同签署流程
EsignHttpResponse
createByFile
=
eSignService
.
createByFile
(
json
);
JsonObject
createByFileJsonObject
=
gson
.
fromJson
(
createByFile
.
getBody
(),
JsonObject
.
class
);
int
code
=
createByFileJsonObject
.
get
(
"code"
).
getAsInt
();
if
(
code
!=
0
)
{
String
message
=
createByFileJsonObject
.
get
(
"message"
).
getAsString
();
throw
new
IllegalStateException
(
"签署失败,原因:"
+
message
);
}
JsonObject
createByFileData
=
createByFileJsonObject
.
getAsJsonObject
(
"data"
);
String
signFlowId
=
createByFileData
.
get
(
"signFlowId"
).
getAsString
();
platformContract
.
setSignFlowId
(
signFlowId
);
// 获取签署链接
EsignHttpResponse
signUrl
=
eSignService
.
signUrl
(
signFlowId
,
account
.
getMobile
());
JsonObject
signUrlJsonObject
=
gson
.
fromJson
(
signUrl
.
getBody
(),
JsonObject
.
class
);
JsonObject
signUrlData
=
signUrlJsonObject
.
getAsJsonObject
(
"data"
);
String
shortUrl
=
signUrlData
.
get
(
"shortUrl"
).
getAsString
();
String
url
=
signUrlData
.
get
(
"url"
).
getAsString
();
log
.
info
(
"平台合同签署流程创建成功, signFlowId: {}, accountId: {}"
,
signFlowId
,
account
.
getAccountId
());
platformContractDao
.
save
(
platformContract
);
return
url
;
}
/**
* 构建平台合同签署流程配置
*/
private
SignFlowConfig
buildPlatformContractSignFlow
(
PlatformContract
contract
,
String
fileId
,
JsonArray
components
)
{
// 从模板组件中获取签署位置信息
SignFlowConfig
.
NormalSignFieldConfig
partASignArea
=
null
;
SignFlowConfig
.
NormalSignFieldConfig
partASignAreaDate
=
null
;
SignFlowConfig
.
NormalSignFieldConfig
partBSignArea
=
null
;
SignFlowConfig
.
NormalSignFieldConfig
partBSignAreaDate
=
null
;
for
(
var
component
:
components
)
{
JsonObject
componentObject
=
component
.
getAsJsonObject
();
String
componentKey
=
componentObject
.
get
(
"componentKey"
).
getAsString
();
JsonObject
componentPosition
=
componentObject
.
getAsJsonObject
(
"componentPosition"
);
SignFlowConfig
.
NormalSignFieldConfig
config
=
buildNormalSignFieldConfig
(
componentPosition
);
switch
(
componentKey
)
{
case
"partASignArea"
->
partASignArea
=
config
;
case
"partASignAreaDate"
->
partASignAreaDate
=
config
;
case
"partBSignArea"
->
partBSignArea
=
config
;
case
"partBSignAreaDate"
->
partBSignAreaDate
=
config
;
}
}
// 构建签署流程配置
Account
account
=
contract
.
getAccount
();
String
contractName
=
contract
.
getContractName
();
// 文档
SignFlowConfig
.
Doc
doc
=
new
SignFlowConfig
.
Doc
(
fileId
,
contractName
);
// 签署配置
SignFlowConfig
.
SignConfig
signConfig
=
new
SignFlowConfig
.
SignConfig
(
"1"
,
true
);
// 签署流程配置详情
SignFlowConfig
.
SignFlowConfigDetail
flowConfigDetail
=
new
SignFlowConfig
.
SignFlowConfigDetail
(
contractName
,
null
,
true
,
true
,
true
,
signConfig
,
eSignService
.
getCallbackUrl
(),
null
,
null
);
// 个人签署人(客户)
SignFlowConfig
.
Signer
psnSigner
=
createPsnSigner
(
account
,
fileId
,
partBSignArea
,
partBSignAreaDate
);
// 机构签署人(平台方)
SignFlowConfig
.
Signer
orgSigner
=
createOrgSigner
(
fileId
,
partASignArea
,
partASignAreaDate
);
return
new
SignFlowConfig
(
List
.
of
(
doc
),
null
,
flowConfigDetail
,
null
,
List
.
of
(
psnSigner
,
orgSigner
),
null
);
}
/**
* 构建普通签署字段配置
*/
private
SignFlowConfig
.
NormalSignFieldConfig
buildNormalSignFieldConfig
(
JsonObject
componentPosition
)
{
String
positionPage
=
componentPosition
.
get
(
"componentPageNum"
).
getAsString
();
double
positionX
=
componentPosition
.
get
(
"componentPositionX"
).
getAsDouble
();
double
positionY
=
componentPosition
.
get
(
"componentPositionY"
).
getAsDouble
();
SignFlowConfig
.
SignFieldPosition
signFieldPosition
=
new
SignFlowConfig
.
SignFieldPosition
(
positionPage
,
positionX
,
positionY
);
return
new
SignFlowConfig
.
NormalSignFieldConfig
(
false
,
// autoSign
false
,
// freeMode
false
,
// movableSignField
null
,
// assignedSealId
null
,
// psnSealStyles
null
,
// signFieldSize
1
,
// signFieldStyle
signFieldPosition
);
}
private
SignFlowConfig
.
Signer
createPsnSigner
(
Account
account
,
String
fileId
,
SignFlowConfig
.
NormalSignFieldConfig
signArea
,
SignFlowConfig
.
NormalSignFieldConfig
signAreaDate
)
{
// 签署配置详情
SignFlowConfig
.
SignConfigDetail
signConfigDetail
=
new
SignFlowConfig
.
SignConfigDetail
(
"5"
,
1
);
// 通知配置
SignFlowConfig
.
NoticeConfig
noticeConfig
=
new
SignFlowConfig
.
NoticeConfig
(
"1"
);
// 签署日期配置
SignFlowConfig
.
SignDateConfig
dateConfig
=
null
;
if
(
signAreaDate
!=
null
&&
signAreaDate
.
signFieldPosition
()
!=
null
)
{
SignFlowConfig
.
SignFieldPosition
position
=
signAreaDate
.
signFieldPosition
();
dateConfig
=
new
SignFlowConfig
.
SignDateConfig
(
"yyyy年MM月dd日"
,
1
,
(
int
)
position
.
positionX
(),
(
int
)
position
.
positionY
());
}
// 个人信息
SignFlowConfig
.
PsnInfo
psnInfo
=
new
SignFlowConfig
.
PsnInfo
(
account
.
getAccountName
(),
account
.
getIdCard
(),
"CRED_PSN_CH_IDCARD"
);
// 签署字段
List
<
SignFlowConfig
.
SignField
>
signFields
=
new
ArrayList
<>();
signFields
.
add
(
new
SignFlowConfig
.
SignField
(
fileId
,
""
,
0
,
signArea
,
dateConfig
,
null
));
// 个人签署人信息
SignFlowConfig
.
PsnSignerInfo
psnSignerInfo
=
new
SignFlowConfig
.
PsnSignerInfo
(
account
.
getMobile
(),
psnInfo
);
return
new
SignFlowConfig
.
Signer
(
signConfigDetail
,
noticeConfig
,
0
,
psnSignerInfo
,
null
,
signFields
);
}
private
SignFlowConfig
.
Signer
createOrgSigner
(
String
fileId
,
SignFlowConfig
.
NormalSignFieldConfig
signArea
,
SignFlowConfig
.
NormalSignFieldConfig
signAreaDate
)
{
// 签署日期配置
SignFlowConfig
.
SignDateConfig
dateConfig
=
null
;
if
(
signAreaDate
!=
null
&&
signAreaDate
.
signFieldPosition
()
!=
null
)
{
SignFlowConfig
.
SignFieldPosition
position
=
signAreaDate
.
signFieldPosition
();
dateConfig
=
new
SignFlowConfig
.
SignDateConfig
(
"yyyy年MM月dd日"
,
1
,
(
int
)
position
.
positionX
(),
(
int
)
position
.
positionY
());
}
// 签署字段
List
<
SignFlowConfig
.
SignField
>
signFields
=
new
ArrayList
<>();
signFields
.
add
(
new
SignFlowConfig
.
SignField
(
fileId
,
""
,
0
,
signArea
,
dateConfig
,
null
));
// 通知配置(不通知)
SignFlowConfig
.
NoticeConfig
noticeConfig
=
new
SignFlowConfig
.
NoticeConfig
(
""
);
return
new
SignFlowConfig
.
Signer
(
null
,
noticeConfig
,
1
,
null
,
null
,
signFields
);
}
/**
* 签署平台合同(e签宝回调)
*
* @param signFlowId 签署流程ID
* @return 平台合同实例对象
*/
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
public
PlatformContract
signPlatformContract
(
String
signFlowId
)
{
PlatformContract
contract
=
platformContractDao
.
findTopBySignFlowId
(
signFlowId
);
if
(
Objects
.
nonNull
(
contract
))
{
contract
.
setContractStatus
(
PlatformContract
.
ContractStatus
.
SIGNED
);
contract
.
setSignTime
(
LocalDateTime
.
now
());
// 更新账户的平台合同签署状态
Account
account
=
contract
.
getAccount
();
account
.
setPlatformContractSigned
(
true
);
account
.
setPlatformContractSignTime
(
LocalDateTime
.
now
());
log
.
info
(
"账户 {} 签署平台合同成功"
,
account
.
getAccountId
());
}
return
contract
;
}
/**
* 重新发起签署(超时后)
*
* @param platformContractId 平台合同ID
* @return 平台合同实例对象
*/
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
public
PlatformContract
resignPlatformContract
(
int
platformContractId
)
{
PlatformContract
contract
=
getPlatformContractById
(
platformContractId
);
if
(
contract
.
getContractStatus
()
==
PlatformContract
.
ContractStatus
.
EXPIRED
||
contract
.
getContractStatus
()
==
PlatformContract
.
ContractStatus
.
PENDING
)
{
contract
.
setContractStatus
(
PlatformContract
.
ContractStatus
.
SIGNING
);
contract
.
setSignDeadline
(
LocalDateTime
.
now
().
plusHours
(
24
));
}
return
contract
;
}
/**
* 更新签署流程ID和文件ID
*
* @param platformContractId 平台合同ID
* @param signFlowId 签署流程ID
* @param fileId e签宝文件ID
*/
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
public
void
updateSignFlowInfo
(
int
platformContractId
,
String
signFlowId
,
String
fileId
)
{
PlatformContract
contract
=
getPlatformContractById
(
platformContractId
);
contract
.
setSignFlowId
(
signFlowId
);
contract
.
setFileId
(
fileId
);
}
/**
* 检查并更新过期合同
*/
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
public
void
checkExpiredContracts
()
{
// 定时任务可以调用此方法检查过期的合同
List
<
PlatformContract
>
expiredContracts
=
platformContractDao
.
findAll
((
root
,
query
,
cb
)
->
cb
.
and
(
cb
.
equal
(
root
.
get
(
"contractStatus"
),
PlatformContract
.
ContractStatus
.
SIGNING
),
cb
.
lessThan
(
root
.
get
(
"signDeadline"
),
LocalDateTime
.
now
())
));
for
(
PlatformContract
contract
:
expiredContracts
)
{
contract
.
setContractStatus
(
PlatformContract
.
ContractStatus
.
EXPIRED
);
log
.
info
(
"平台合同 {} 已过期"
,
contract
.
getContractCode
());
}
}
}
aus-core/src/main/java/com/glsx/usedcar/module/account/vo/PlatformContractPageQueryVO.java
0 → 100644
View file @
7dffb96
package
com
.
glsx
.
usedcar
.
module
.
account
.
vo
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.time.LocalDate
;
/**
* 平台合同分页查询请求VO
*
* @author yangwei
* @since 2026-08-04
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema
(
description
=
"平台合同分页查询请求参数"
)
public
class
PlatformContractPageQueryVO
{
@Schema
(
description
=
"页码,默认1(从1开始)"
,
example
=
"1"
)
private
Integer
page
;
@Schema
(
description
=
"每页条数,默认20"
,
example
=
"20"
)
private
Integer
size
;
@Schema
(
description
=
"合同编号,模糊匹配"
,
example
=
"HT20260804"
)
private
String
contractCode
;
@Schema
(
description
=
"签署人姓名,模糊匹配"
,
example
=
"张三"
)
private
String
signerName
;
@Schema
(
description
=
"签署人手机号,精确匹配"
,
example
=
"13800138000"
)
private
String
signerMobile
;
@Schema
(
description
=
"合同状态:PENDING-待签署/SIGNING-签署中/SIGNED-已签署/EXPIRED-已过期/CANCELLED-已作废"
,
example
=
"SIGNED"
)
private
String
contractStatus
;
@Schema
(
description
=
"账户ID"
,
example
=
"1"
)
private
Integer
accountId
;
@Schema
(
description
=
"账户名称,模糊匹配"
,
example
=
"李四"
)
private
String
accountName
;
@Schema
(
description
=
"创建时间-起始"
,
example
=
"2026-08-01"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
,
timezone
=
"GMT+8"
)
private
LocalDate
createTimeStart
;
@Schema
(
description
=
"创建时间-结束"
,
example
=
"2026-08-04"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
,
timezone
=
"GMT+8"
)
private
LocalDate
createTimeEnd
;
}
aus-core/src/main/java/com/glsx/usedcar/module/account/vo/PlatformContractPageRespVO.java
0 → 100644
View file @
7dffb96
package
com
.
glsx
.
usedcar
.
module
.
account
.
vo
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.time.LocalDateTime
;
/**
* 平台合同分页查询响应VO
*
* @author yangwei
* @since 2026-08-04
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema
(
description
=
"平台合同分页查询响应"
)
public
class
PlatformContractPageRespVO
{
@Schema
(
description
=
"平台合同ID"
)
private
Integer
platformContractId
;
@Schema
(
description
=
"合同编号"
)
private
String
contractCode
;
@Schema
(
description
=
"合同名称"
)
private
String
contractName
;
@Schema
(
description
=
"账户ID"
)
private
Integer
accountId
;
@Schema
(
description
=
"账户名称"
)
private
String
accountName
;
@Schema
(
description
=
"账户手机号"
)
private
String
accountMobile
;
@Schema
(
description
=
"签署人姓名"
)
private
String
signerName
;
@Schema
(
description
=
"签署人手机号"
)
private
String
signerMobile
;
@Schema
(
description
=
"签署人身份证"
)
private
String
signerIdCard
;
@Schema
(
description
=
"合同状态:PENDING-待签署/SIGNING-签署中/SIGNED-已签署/EXPIRED-已过期/CANCELLED-已作废"
)
private
String
contractStatus
;
@Schema
(
description
=
"合同状态描述"
)
private
String
contractStatusDesc
;
@Schema
(
description
=
"签署时间"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
LocalDateTime
signTime
;
@Schema
(
description
=
"签署截止时间"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
LocalDateTime
signDeadline
;
@Schema
(
description
=
"创建时间"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
LocalDateTime
createTime
;
}
aus-core/src/main/java/com/glsx/usedcar/module/account/vo/PlatformContractRespVO.java
0 → 100644
View file @
7dffb96
package
com
.
glsx
.
usedcar
.
module
.
account
.
vo
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.summerframework.storage.domain.FileInfo
;
import
java.time.LocalDateTime
;
import
java.util.List
;
/**
* 平台合同详情响应VO
*
* @author yangwei
* @since 2026-08-04
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema
(
description
=
"平台合同详情响应"
)
public
class
PlatformContractRespVO
{
@Schema
(
description
=
"平台合同ID"
)
private
Integer
platformContractId
;
@Schema
(
description
=
"合同编号"
)
private
String
contractCode
;
@Schema
(
description
=
"合同名称"
)
private
String
contractName
;
@Schema
(
description
=
"账户ID"
)
private
Integer
accountId
;
@Schema
(
description
=
"账户名称"
)
private
String
accountName
;
@Schema
(
description
=
"账户手机号"
)
private
String
accountMobile
;
@Schema
(
description
=
"签署人姓名"
)
private
String
signerName
;
@Schema
(
description
=
"签署人手机号"
)
private
String
signerMobile
;
@Schema
(
description
=
"签署人身份证"
)
private
String
signerIdCard
;
@Schema
(
description
=
"合同状态:PENDING-待签署/SIGNING-签署中/SIGNED-已签署/EXPIRED-已过期/CANCELLED-已作废"
)
private
String
contractStatus
;
@Schema
(
description
=
"合同状态描述"
)
private
String
contractStatusDesc
;
@Schema
(
description
=
"合同内容"
)
private
String
contractContent
;
@Schema
(
description
=
"合同附件"
)
private
List
<
FileInfo
>
contractFiles
;
@Schema
(
description
=
"e签宝文件ID"
)
private
String
fileId
;
@Schema
(
description
=
"合同签署流程ID"
)
private
String
signFlowId
;
@Schema
(
description
=
"签署时间"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
LocalDateTime
signTime
;
@Schema
(
description
=
"签署截止时间"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
LocalDateTime
signDeadline
;
@Schema
(
description
=
"创建时间"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
LocalDateTime
createTime
;
@Schema
(
description
=
"更新时间"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
LocalDateTime
updateTime
;
}
aus-core/src/main/java/com/glsx/usedcar/module/auction/entity/AuctionOrder.java
View file @
7dffb96
...
@@ -122,6 +122,20 @@ public class AuctionOrder extends AuditingEntity implements Serializable {
...
@@ -122,6 +122,20 @@ public class AuctionOrder extends AuditingEntity implements Serializable {
private
List
<
FileInfo
>
vehicleLicense
;
private
List
<
FileInfo
>
vehicleLicense
;
/**
/**
* 过户发票PDF
*/
@Convert
(
converter
=
FileInfosConverter
.
class
)
@Column
(
nullable
=
true
)
private
List
<
FileInfo
>
transferInvoice
;
/**
* 新车主身份证照片
*/
@Convert
(
converter
=
FileInfosConverter
.
class
)
@Column
(
nullable
=
true
)
private
List
<
FileInfo
>
newOwnerIdCard
;
/**
* 成交价
* 成交价
*/
*/
@Column
@Column
...
@@ -232,7 +246,7 @@ public class AuctionOrder extends AuditingEntity implements Serializable {
...
@@ -232,7 +246,7 @@ public class AuctionOrder extends AuditingEntity implements Serializable {
this
.
account
=
account
;
this
.
account
=
account
;
this
.
vehicle
=
vehicle
;
this
.
vehicle
=
vehicle
;
this
.
auction
=
auction
;
this
.
auction
=
auction
;
this
.
orderState
=
OrderState
.
CONTRACT_UNSIGNE
D
;
this
.
orderState
=
OrderState
.
UNPAI
D
;
}
}
/**
/**
...
@@ -268,8 +282,10 @@ public class AuctionOrder extends AuditingEntity implements Serializable {
...
@@ -268,8 +282,10 @@ public class AuctionOrder extends AuditingEntity implements Serializable {
public
enum
OrderState
{
public
enum
OrderState
{
/**
/**
* 待签署合同
* 待签署合同(已废弃,历史数据已迁移为 UNPAID)
* @deprecated 使用 UNPAID 代替
*/
*/
@Deprecated
CONTRACT_UNSIGNED
,
CONTRACT_UNSIGNED
,
/**
/**
* 待付车款
* 待付车款
...
...
aus-core/src/main/java/com/glsx/usedcar/module/auction/entity/ContractTemplate.java
View file @
7dffb96
...
@@ -92,6 +92,12 @@ public class ContractTemplate extends AuditingEntity implements Serializable {
...
@@ -92,6 +92,12 @@ public class ContractTemplate extends AuditingEntity implements Serializable {
@Column
(
nullable
=
true
,
length
=
128
)
@Column
(
nullable
=
true
,
length
=
128
)
private
String
esignId
;
private
String
esignId
;
/**
* 平台方签约公司名称(仅平台合同模板需要)
*/
@Column
(
nullable
=
true
,
length
=
128
)
private
String
platformSignCompanyName
;
public
enum
TemplateType
{
public
enum
TemplateType
{
/**
/**
* 拍卖合同
* 拍卖合同
...
@@ -100,6 +106,10 @@ public class ContractTemplate extends AuditingEntity implements Serializable {
...
@@ -100,6 +106,10 @@ public class ContractTemplate extends AuditingEntity implements Serializable {
/**
/**
* 交付合同
* 交付合同
*/
*/
DELIVERY
;
DELIVERY
,
/**
* 平台交易整体合同
*/
PLATFORM
;
}
}
}
}
\ No newline at end of file
\ No newline at end of file
aus-core/src/main/java/com/glsx/usedcar/module/auction/entity/vo/ProxyUploadPayVoucherVO.java
0 → 100644
View file @
7dffb96
package
com
.
glsx
.
usedcar
.
module
.
auction
.
entity
.
vo
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
jakarta.validation.constraints.NotNull
;
import
lombok.Data
;
import
org.summerframework.storage.domain.FileInfo
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
java.util.List
;
/**
* 后台代上传付款凭证请求VO
*
* @author claude
* @since 2026-08-05
*/
@Data
@Schema
(
description
=
"后台代上传付款凭证请求参数"
)
public
class
ProxyUploadPayVoucherVO
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
1L
;
@NotNull
(
message
=
"订单ID不能为空"
)
@Schema
(
description
=
"订单ID"
,
required
=
true
,
example
=
"1"
)
private
Integer
orderId
;
@Schema
(
description
=
"付款凭证文件列表"
)
private
List
<
FileInfo
>
payVouchers
;
}
aus-core/src/main/java/com/glsx/usedcar/module/auction/entity/vo/ProxyUploadTransferMaterialsVO.java
0 → 100644
View file @
7dffb96
package
com
.
glsx
.
usedcar
.
module
.
auction
.
entity
.
vo
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
jakarta.validation.constraints.NotNull
;
import
lombok.Data
;
import
org.summerframework.storage.domain.FileInfo
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
java.util.List
;
/**
* 后台代上传过户资料请求VO
*
* @author claude
* @since 2026-08-05
*/
@Data
@Schema
(
description
=
"后台代上传过户资料请求参数"
)
public
class
ProxyUploadTransferMaterialsVO
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
1L
;
@NotNull
(
message
=
"订单ID不能为空"
)
@Schema
(
description
=
"订单ID"
,
required
=
true
,
example
=
"1"
)
private
Integer
orderId
;
@Schema
(
description
=
"新车牌号"
)
private
String
newPlateNumber
;
@Schema
(
description
=
"机动车登记证书"
)
private
List
<
FileInfo
>
registrationCertificate
;
@Schema
(
description
=
"机动车行驶证"
)
private
List
<
FileInfo
>
vehicleLicense
;
@Schema
(
description
=
"过户发票"
)
private
List
<
FileInfo
>
transferInvoice
;
@Schema
(
description
=
"新车主身份证"
)
private
List
<
FileInfo
>
newOwnerIdCard
;
}
aus-core/src/main/java/com/glsx/usedcar/module/auction/entity/vo/UpdateVehicleDocumentsVO.java
0 → 100644
View file @
7dffb96
package
com
.
glsx
.
usedcar
.
module
.
auction
.
entity
.
vo
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
jakarta.validation.constraints.NotNull
;
import
lombok.Data
;
import
org.summerframework.storage.domain.FileInfo
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
java.util.List
;
/**
* 更新车务资料请求VO
*
* @author claude
* @since 2026-08-05
*/
@Data
@Schema
(
description
=
"更新车务资料请求参数"
)
public
class
UpdateVehicleDocumentsVO
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
1L
;
@NotNull
(
message
=
"订单ID不能为空"
)
@Schema
(
description
=
"订单ID"
,
required
=
true
,
example
=
"1"
)
private
Integer
orderId
;
@Schema
(
description
=
"机动车登记证书"
)
private
List
<
FileInfo
>
registrationCertificate
;
@Schema
(
description
=
"机动车行驶证"
)
private
List
<
FileInfo
>
vehicleLicense
;
}
aus-core/src/main/java/com/glsx/usedcar/module/auction/service/AuctionOrderService.java
View file @
7dffb96
...
@@ -24,6 +24,7 @@ import com.glsx.usedcar.module.meta.AuditState;
...
@@ -24,6 +24,7 @@ import com.glsx.usedcar.module.meta.AuditState;
import
com.glsx.usedcar.module.track.dao.ApproveHistoryDao
;
import
com.glsx.usedcar.module.track.dao.ApproveHistoryDao
;
import
com.glsx.usedcar.module.track.entity.ApproveHistory
;
import
com.glsx.usedcar.module.track.entity.ApproveHistory
;
import
com.glsx.usedcar.module.vehicle.entity.Vehicle
;
import
com.glsx.usedcar.module.vehicle.entity.Vehicle
;
import
com.glsx.usedcar.module.venue.entity.Outbound
;
import
com.glsx.usedcar.module.vrsystem.service.VrAuditService
;
import
com.glsx.usedcar.module.vrsystem.service.VrAuditService
;
import
com.glsx.usedcar.resp.BaseResp
;
import
com.glsx.usedcar.resp.BaseResp
;
import
com.glsx.usedcar.util.CoderGenerator
;
import
com.glsx.usedcar.util.CoderGenerator
;
...
@@ -219,13 +220,6 @@ public class AuctionOrderService extends AbstractAuctionService {
...
@@ -219,13 +220,6 @@ public class AuctionOrderService extends AbstractAuctionService {
CompletableFuture
<
Long
>
totalFuture
=
CompletableFuture
.
supplyAsync
(()
->
CompletableFuture
<
Long
>
totalFuture
=
CompletableFuture
.
supplyAsync
(()
->
pageAuctionOrder
(
pagination
.
copyForCount
()).
getTotalElements
(),
ioIntensiveExecutor
);
pageAuctionOrder
(
pagination
.
copyForCount
()).
getTotalElements
(),
ioIntensiveExecutor
);
// 待签署合同
CompletableFuture
<
Long
>
contractUnsignedFuture
=
CompletableFuture
.
supplyAsync
(()
->
{
Pagination
<
AuctionOrder
>
p
=
pagination
.
copyForCount
();
p
.
addFilter
(
AuctionOrder
.
OrderState
.
CONTRACT_UNSIGNED
,
org
.
summerframework
.
orm
.
paging
.
Operator
.
eq
,
AuctionOrder_
.
orderState
);
return
pageAuctionOrder
(
p
).
getTotalElements
();
},
ioIntensiveExecutor
);
// 待付车款
// 待付车款
CompletableFuture
<
Long
>
unpaidFuture
=
CompletableFuture
.
supplyAsync
(()
->
{
CompletableFuture
<
Long
>
unpaidFuture
=
CompletableFuture
.
supplyAsync
(()
->
{
Pagination
<
AuctionOrder
>
p
=
pagination
.
copyForCount
();
Pagination
<
AuctionOrder
>
p
=
pagination
.
copyForCount
();
...
@@ -261,12 +255,12 @@ public class AuctionOrderService extends AbstractAuctionService {
...
@@ -261,12 +255,12 @@ public class AuctionOrderService extends AbstractAuctionService {
return
pageAuctionOrder
(
p
).
getTotalElements
();
return
pageAuctionOrder
(
p
).
getTotalElements
();
},
ioIntensiveExecutor
);
},
ioIntensiveExecutor
);
CompletableFuture
.
allOf
(
totalFuture
,
contractUnsignedFuture
,
unpaidFuture
,
CompletableFuture
.
allOf
(
totalFuture
,
unpaidFuture
,
waitPickupFuture
,
transferringFuture
,
completedFuture
,
canceledFuture
).
join
();
waitPickupFuture
,
transferringFuture
,
completedFuture
,
canceledFuture
).
join
();
return
AuctionOrderStateCountRespVO
.
builder
()
return
AuctionOrderStateCountRespVO
.
builder
()
.
total
(
totalFuture
.
join
())
.
total
(
totalFuture
.
join
())
.
contractUnsignedCount
(
contractUnsignedFuture
.
join
())
.
contractUnsignedCount
(
0L
)
// 已废弃,固定返回0
.
unpaidCount
(
unpaidFuture
.
join
())
.
unpaidCount
(
unpaidFuture
.
join
())
.
waitPickupCount
(
waitPickupFuture
.
join
())
.
waitPickupCount
(
waitPickupFuture
.
join
())
.
transferringCount
(
transferringFuture
.
join
())
.
transferringCount
(
transferringFuture
.
join
())
...
@@ -326,22 +320,51 @@ public class AuctionOrderService extends AbstractAuctionService {
...
@@ -326,22 +320,51 @@ public class AuctionOrderService extends AbstractAuctionService {
/**
/**
* 上传过户资料
* 上传过户资料
* <p>
* 车商在待过户状态下上传过户资料,提交后进入审核中状态
* 支持上传:机动车登记证书、新机动车行驶证、新车牌号、过户发票PDF、新车主身份证照片
* </p>
*
*
* @param order
* @param order
包含过户资料的订单对象
* @return
* @return
更新后的订单
* @throws FieldException
* @throws FieldException
如果订单状态不正确
*/
*/
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
public
AuctionOrder
uploadTransferAuctionOrder
(
AuctionOrder
order
)
throws
FieldException
{
public
AuctionOrder
uploadTransferAuctionOrder
(
AuctionOrder
order
)
throws
FieldException
{
log
.
info
(
"上传过户资料开始, orderId: {}, newPlateNumber: {}, hasRegistrationCertificate: {}, hasVehicleLicense: {}, hasTransferInvoice: {}, hasNewOwnerIdCard: {}"
,
order
.
getOrderId
(),
order
.
getNewPlateNumber
(),
order
.
getRegistrationCertificate
()
!=
null
&&
!
order
.
getRegistrationCertificate
().
isEmpty
(),
order
.
getVehicleLicense
()
!=
null
&&
!
order
.
getVehicleLicense
().
isEmpty
(),
order
.
getTransferInvoice
()
!=
null
&&
!
order
.
getTransferInvoice
().
isEmpty
(),
order
.
getNewOwnerIdCard
()
!=
null
&&
!
order
.
getNewOwnerIdCard
().
isEmpty
());
AuctionOrder
auctionOrder
=
auctionOrderDao
.
findByOrderId
(
order
.
getOrderId
());
AuctionOrder
auctionOrder
=
auctionOrderDao
.
findByOrderId
(
order
.
getOrderId
());
if
(!
auctionOrder
.
equalsOrderState
(
AuctionOrder
.
OrderState
.
TRANSFERRING
))
{
if
(!
auctionOrder
.
equalsOrderState
(
AuctionOrder
.
OrderState
.
TRANSFERRING
))
{
log
.
warn
(
"上传过户资料失败, 订单状态不正确, orderId: {}, currentOrderState: {}, expectedOrderState: {}"
,
order
.
getOrderId
(),
auctionOrder
.
getOrderState
(),
AuctionOrder
.
OrderState
.
TRANSFERRING
);
throw
new
FieldException
(
"orderState"
,
auctionOrder
,
"订单状态不正确"
);
throw
new
FieldException
(
"orderState"
,
auctionOrder
,
"订单状态不正确"
);
}
}
// 设置为上传过户资料审核等待中
// 设置为上传过户资料审核等待中
auctionOrder
.
setAuditState
(
AuditState
.
UNAUDITED
);
auctionOrder
.
setAuditState
(
AuditState
.
UNAUDITED
);
// 更新过户资料字段
auctionOrder
.
setNewPlateNumber
(
order
.
getNewPlateNumber
());
auctionOrder
.
setNewPlateNumber
(
order
.
getNewPlateNumber
());
auctionOrder
.
setRegistrationCertificate
(
order
.
getRegistrationCertificate
());
auctionOrder
.
setRegistrationCertificate
(
order
.
getRegistrationCertificate
());
auctionOrder
.
setVehicleLicense
(
order
.
getVehicleLicense
());
auctionOrder
.
setVehicleLicense
(
order
.
getVehicleLicense
());
// 新增字段:过户发票PDF、新车主身份证照片
auctionOrder
.
setTransferInvoice
(
order
.
getTransferInvoice
());
auctionOrder
.
setNewOwnerIdCard
(
order
.
getNewOwnerIdCard
());
log
.
info
(
"上传过户资料成功, orderId: {}, auditState: {}, newPlateNumber: {}, registrationCertificateCount: {}, vehicleLicenseCount: {}, transferInvoiceCount: {}, newOwnerIdCardCount: {}"
,
auctionOrder
.
getOrderId
(),
auctionOrder
.
getAuditState
(),
auctionOrder
.
getNewPlateNumber
(),
auctionOrder
.
getRegistrationCertificate
()
!=
null
?
auctionOrder
.
getRegistrationCertificate
().
size
()
:
0
,
auctionOrder
.
getVehicleLicense
()
!=
null
?
auctionOrder
.
getVehicleLicense
().
size
()
:
0
,
auctionOrder
.
getTransferInvoice
()
!=
null
?
auctionOrder
.
getTransferInvoice
().
size
()
:
0
,
auctionOrder
.
getNewOwnerIdCard
()
!=
null
?
auctionOrder
.
getNewOwnerIdCard
().
size
()
:
0
);
// 发送通知消息
// 发送通知消息
sendNoticeMessage
(
NoticeTemplate
.
TemplateType
.
TRANSFER_AUDIT
,
Map
.
of
(
sendNoticeMessage
(
NoticeTemplate
.
TemplateType
.
TRANSFER_AUDIT
,
Map
.
of
(
...
@@ -395,6 +418,59 @@ public class AuctionOrderService extends AbstractAuctionService {
...
@@ -395,6 +418,59 @@ public class AuctionOrderService extends AbstractAuctionService {
}
}
/**
/**
* 确认提车(无交付合同签署依赖)
* <p>
* 简化后的确认提车流程:用户直接点击确认提车,无需签署交付合同
* 订单状态从待提车变为待过户
* </p>
*
* @param orderId 订单ID
* @param account 当前账户
* @return 更新后的订单
* @throws FieldException 如果订单状态不正确
*/
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
public
AuctionOrder
confirmPickup
(
int
orderId
,
Account
account
)
throws
FieldException
{
AuctionOrder
auctionOrder
=
auctionOrderDao
.
findByOrderId
(
orderId
);
// 校验订单归属
if
(
auctionOrder
.
getAccount
().
getAccountId
()
!=
account
.
getAccountId
())
{
throw
new
FieldException
(
"orderId"
,
orderId
,
"无权操作此订单"
);
}
// 校验订单状态:必须为待提车
if
(!
auctionOrder
.
equalsOrderState
(
AuctionOrder
.
OrderState
.
WAIT_PICKUP
))
{
throw
new
FieldException
(
"orderState"
,
auctionOrder
,
"订单状态不正确,仅待提车订单可确认提车"
);
}
// 更新订单状态为待过户
auctionOrder
.
resetOrderState
(
AuctionOrder
.
OrderState
.
TRANSFERRING
,
Vehicle
.
VehicleState
.
TRANSFERRING
);
gscInvoker
.
pushAuction
(
auctionOrder
);
// 进入待过户状态,将审核状态改为null
auctionOrder
.
setAuditState
(
null
);
// 发送短信给用户,提醒用户上传过户资料
Vehicle
vehicle
=
auctionOrder
.
getVehicle
();
String
vehicleName
=
vehicle
.
getBaseInfo
().
getCarSeriesName
()
+
" "
+
vehicle
.
getBaseInfo
().
getCarTypeName
();
Object
[]
args
=
{
vehicleName
,
auctionOrder
.
getOrderCode
(),
"7"
};
String
message
=
messageSource
.
getMessage
(
"sms.auction.order.transfer.notice"
,
args
,
Locale
.
CHINESE
);
String
mobile
=
auctionOrder
.
getAccount
().
getMobile
();
gscApiInvoker
.
sendMsg
(
mobile
,
message
);
log
.
info
(
"确认提车成功,发送短信 to {} for transfer notice: {} "
,
mobile
,
message
);
// 记录出库记录
Outbound
outbound
=
new
Outbound
(
auctionOrder
,
Outbound
.
OutboundType
.
AUTO
,
Outbound
.
OutboundMethod
.
DELIVERY
);
// 保存出库记录需要注入 OutboundDao
// outboundDao.save(outbound);
AuctionVehicle
auctionAndVehicle
=
auctionVehicleDao
.
findTopByAuctionAndVehicle
(
auctionOrder
.
getAuction
(),
auctionOrder
.
getVehicle
());
vrAuditService
.
syncVrAuditStatus
(
auctionAndVehicle
);
return
auctionOrder
;
}
/**
* 通过拍卖订单主键删除数据
* 通过拍卖订单主键删除数据
*
*
* @param orderId 主键
* @param orderId 主键
...
@@ -413,6 +489,17 @@ public class AuctionOrderService extends AbstractAuctionService {
...
@@ -413,6 +489,17 @@ public class AuctionOrderService extends AbstractAuctionService {
return
(
int
)
auctionOrderDao
.
countByAccountAndOrderState
(
account
,
orderState
);
return
(
int
)
auctionOrderDao
.
countByAccountAndOrderState
(
account
,
orderState
);
}
}
/**
* 更新拍卖订单(用于后台代上传等场景)
*
* @param auctionOrder 拍卖订单
* @return 更新后的订单
*/
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
public
AuctionOrder
updateAuctionOrder
(
AuctionOrder
auctionOrder
)
{
return
auctionOrderDao
.
save
(
auctionOrder
);
}
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
public
void
autoGenerateAuctionOrders
()
{
public
void
autoGenerateAuctionOrders
()
{
LocalDateTime
now
=
LocalDateTime
.
now
();
LocalDateTime
now
=
LocalDateTime
.
now
();
...
@@ -468,7 +555,7 @@ public class AuctionOrderService extends AbstractAuctionService {
...
@@ -468,7 +555,7 @@ public class AuctionOrderService extends AbstractAuctionService {
auctionOrder
.
setCommissionPrice
(
commissionPrice
);
auctionOrder
.
setCommissionPrice
(
commissionPrice
);
auctionOrder
=
auctionOrderDao
.
save
(
auctionOrder
);
auctionOrder
=
auctionOrderDao
.
save
(
auctionOrder
);
auctionVehicle
.
setAuctionState
(
AuctionVehicle
.
AuctionState
.
SOLD
);
auctionVehicle
.
setAuctionState
(
AuctionVehicle
.
AuctionState
.
SOLD
);
vehicle
.
setVehicleState
(
Vehicle
.
VehicleState
.
CONTRACT_UNSIGNE
D
);
vehicle
.
setVehicleState
(
Vehicle
.
VehicleState
.
UNPAI
D
);
// 更新已经拍卖数量
// 更新已经拍卖数量
auction
.
setAuctionedCount
((
int
)
auctionVehicleDao
.
countByAuctionStateAndAuction
(
AuctionVehicle
.
AuctionState
.
SOLD
,
auction
));
auction
.
setAuctionedCount
((
int
)
auctionVehicleDao
.
countByAuctionStateAndAuction
(
AuctionVehicle
.
AuctionState
.
SOLD
,
auction
));
// 退还保证金
// 退还保证金
...
...
aus-core/src/main/java/com/glsx/usedcar/module/auction/service/BidService.java
View file @
7dffb96
...
@@ -2,6 +2,7 @@ package com.glsx.usedcar.module.auction.service;
...
@@ -2,6 +2,7 @@ package com.glsx.usedcar.module.auction.service;
import
com.glsx.usedcar.module.account.dao.AccountDao
;
import
com.glsx.usedcar.module.account.dao.AccountDao
;
import
com.glsx.usedcar.module.account.entity.Account
;
import
com.glsx.usedcar.module.account.entity.Account
;
import
com.glsx.usedcar.module.account.service.PlatformContractService
;
import
com.glsx.usedcar.module.analysis.domain.IndexValue
;
import
com.glsx.usedcar.module.analysis.domain.IndexValue
;
import
com.glsx.usedcar.module.auction.dao.*
;
import
com.glsx.usedcar.module.auction.dao.*
;
import
com.glsx.usedcar.module.auction.domain.BidStat
;
import
com.glsx.usedcar.module.auction.domain.BidStat
;
...
@@ -62,6 +63,9 @@ public class BidService {
...
@@ -62,6 +63,9 @@ public class BidService {
@Autowired
@Autowired
private
LightAuctionPoollingBidService
lightAuctionPoollingBidService
;
private
LightAuctionPoollingBidService
lightAuctionPoollingBidService
;
@Resource
private
PlatformContractService
platformContractService
;
/**
/**
* 通过ID查询一个投标竞价
* 通过ID查询一个投标竞价
...
@@ -147,6 +151,11 @@ public class BidService {
...
@@ -147,6 +151,11 @@ public class BidService {
throw
new
FieldException
(
"accountId"
,
accountId
,
"你已被禁止竞价"
);
throw
new
FieldException
(
"accountId"
,
accountId
,
"你已被禁止竞价"
);
}
}
// 检查是否已签署平台合同(历史已认证用户首次出价需签署平台合同)
if
(
account
.
getCertifiedState
()
==
Account
.
CertifiedState
.
CERTIFIED
&&
!
platformContractService
.
hasSignedPlatformContract
(
accountId
))
{
throw
new
FieldException
(
"platformContract"
,
accountId
,
"请先签署平台交易整体合同"
);
}
Auction
auction
=
auctionVehicle
.
getAuction
();
Auction
auction
=
auctionVehicle
.
getAuction
();
// 用户标签校验
// 用户标签校验
if
(
auction
.
getAccessScope
()
==
Auction
.
AccessScope
.
TAGS
&&
!
auction
.
getAccountTags
().
isEmpty
())
{
if
(
auction
.
getAccessScope
()
==
Auction
.
AccessScope
.
TAGS
&&
!
auction
.
getAccountTags
().
isEmpty
())
{
...
...
aus-core/src/main/java/com/glsx/usedcar/module/auction/service/ContractService.java
View file @
7dffb96
...
@@ -249,6 +249,9 @@ public class ContractService {
...
@@ -249,6 +249,9 @@ public class ContractService {
/**
/**
* 签署合同
* 签署合同
* 注意:拍卖合同和交付合同的状态流转逻辑已移除
* - 订单初始状态已改为 UNPAID,不再需要拍卖合同签署后流转
* - 确认提车不再需要签署交付合同
*
*
* @param signFlowId 签署流程ID
* @param signFlowId 签署流程ID
* @return 合同实例对象
* @return 合同实例对象
...
@@ -259,43 +262,8 @@ public class ContractService {
...
@@ -259,43 +262,8 @@ public class ContractService {
if
(
Objects
.
nonNull
(
contract
))
{
if
(
Objects
.
nonNull
(
contract
))
{
contract
.
setSigned
(
true
);
contract
.
setSigned
(
true
);
contract
.
setSignTime
(
LocalDateTime
.
now
());
contract
.
setSignTime
(
LocalDateTime
.
now
());
AuctionOrder
auctionOrder
=
contract
.
getAuctionOrder
();
// 拍卖合同和交付合同签署后不再触发状态流转
if
(
contract
.
getTemplateType
()
==
ContractTemplate
.
TemplateType
.
AUCTION
)
{
// 订单初始状态已改为 UNPAID,确认提车不再需要签署交付合同
// 拍卖合同签署成功,订单状态改为待支付
if
(
auctionOrder
.
equalsOrderState
(
AuctionOrder
.
OrderState
.
CONTRACT_UNSIGNED
))
{
auctionOrder
.
resetOrderState
(
AuctionOrder
.
OrderState
.
UNPAID
,
Vehicle
.
VehicleState
.
UNPAID
);
DeliveryOrder
deliveryOrder
=
generateDeliveryOrder
(
auctionOrder
);
// 推送交付工单
AuctionVehicle
auctionAndVehicle
=
auctionVehicleDao
.
findTopByAuctionAndVehicle
(
auctionOrder
.
getAuction
(),
auctionOrder
.
getVehicle
());
gscInvoker
.
pushAuction
(
auctionAndVehicle
,
auctionOrder
);
gscInvoker
.
pushDeliveryOrder
(
deliveryOrder
,
auctionAndVehicle
);
vrAuditService
.
syncVrAuditStatus
(
auctionAndVehicle
);
}
}
else
if
(
contract
.
getTemplateType
()
==
ContractTemplate
.
TemplateType
.
DELIVERY
)
{
// 交付合同签署成功,订单状态改为待过户状态
if
(
auctionOrder
.
equalsOrderState
(
AuctionOrder
.
OrderState
.
WAIT_PICKUP
))
{
auctionOrder
.
resetOrderState
(
AuctionOrder
.
OrderState
.
TRANSFERRING
,
Vehicle
.
VehicleState
.
TRANSFERRING
);
gscInvoker
.
pushAuction
(
auctionOrder
);
gscInvoker
.
signFinishDeliveryOrder
(
auctionOrder
);
// 进入待过户状态,将审核状态改为null
auctionOrder
.
setAuditState
(
null
);
// 发送短信给用户,提醒用户上传过户资料
Vehicle
vehicle
=
auctionOrder
.
getVehicle
();
String
vehicleName
=
vehicle
.
getBaseInfo
().
getCarSeriesName
()
+
" "
+
vehicle
.
getBaseInfo
().
getCarTypeName
();
Object
[]
args
=
{
vehicleName
,
auctionOrder
.
getOrderCode
(),
"7"
};
String
message
=
messageSource
.
getMessage
(
"sms.auction.order.transfer.notice"
,
args
,
Locale
.
CHINESE
);
String
mobile
=
auctionOrder
.
getAccount
().
getMobile
();
gscApiInvoker
.
sendMsg
(
mobile
,
message
);
log
.
info
(
"发送短信 to {} for transfer notice: {} "
,
mobile
,
message
);
// 记录出库记录
Outbound
outbound
=
new
Outbound
(
auctionOrder
,
Outbound
.
OutboundType
.
AUTO
,
Outbound
.
OutboundMethod
.
DELIVERY
);
outboundDao
.
save
(
outbound
);
AuctionVehicle
auctionAndVehicle
=
auctionVehicleDao
.
findTopByAuctionAndVehicle
(
auctionOrder
.
getAuction
(),
auctionOrder
.
getVehicle
());
vrAuditService
.
syncVrAuditStatus
(
auctionAndVehicle
);
}
}
}
}
return
contract
;
return
contract
;
}
}
...
...
aus-core/src/main/java/com/glsx/usedcar/module/auction/service/DeliveryOrderService.java
View file @
7dffb96
...
@@ -13,16 +13,22 @@ import org.springframework.transaction.annotation.Propagation;
...
@@ -13,16 +13,22 @@ import org.springframework.transaction.annotation.Propagation;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.summerframework.orm.paging.Pagination
;
import
org.summerframework.orm.paging.Pagination
;
import
java.time.LocalDateTime
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.Objects
;
/**
/**
* 交付订单(DeliveryOrder) 服务实现类
* 交付订单(DeliveryOrder) 服务实现类
* <p>
*
* @deprecated 交付单功能已废弃,新订单不再创建交付单。
* 车商确认提车不再依赖交付单,历史交付单数据仍可查询。
* 相关方法保留用于历史数据查询。
* </p>
*
*
* @since 2025-10-13 12:18:11
* @since 2025-10-13 12:18:11
*/
*/
@Deprecated
@Service
@Service
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
)
public
class
DeliveryOrderService
{
public
class
DeliveryOrderService
{
...
@@ -66,16 +72,12 @@ public class DeliveryOrderService {
...
@@ -66,16 +72,12 @@ public class DeliveryOrderService {
*
*
* @param deliveryOrder 交付订单实例对象
* @param deliveryOrder 交付订单实例对象
* @return 交付订单实例对象
* @return 交付订单实例对象
* @deprecated 交付单功能已废弃,新订单不再创建交付单,此方法始终返回 null
*/
*/
@Deprecated
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
public
DeliveryOrder
assignDeliveryOrder
(
DeliveryOrder
deliveryOrder
)
{
public
DeliveryOrder
assignDeliveryOrder
(
DeliveryOrder
deliveryOrder
)
{
DeliveryOrder
deliveryOrderDb
=
deliveryOrderDao
.
updateById
(
deliveryOrder
,
return
null
;
DeliveryOrder_
.
user
,
DeliveryOrder_
.
remark
);
deliveryOrderDb
.
setAssignedTime
(
LocalDateTime
.
now
());
deliveryOrderDb
.
setOrderState
(
DeliveryOrder
.
OrderState
.
UNDELIVERED
);
return
deliveryOrderDb
;
}
}
/**
/**
...
@@ -83,18 +85,12 @@ public class DeliveryOrderService {
...
@@ -83,18 +85,12 @@ public class DeliveryOrderService {
*
*
* @param deliveryOrder 交付订单实例对象
* @param deliveryOrder 交付订单实例对象
* @return 交付订单实例对象
* @return 交付订单实例对象
* @deprecated 交付单功能已废弃,此方法始终返回 null
*/
*/
@Deprecated
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
public
DeliveryOrder
handleDeliveryOrder
(
DeliveryOrder
deliveryOrder
)
{
public
DeliveryOrder
handleDeliveryOrder
(
DeliveryOrder
deliveryOrder
)
{
DeliveryOrder
deliveryOrderDb
=
deliveryOrderDao
.
updateById
(
deliveryOrder
,
return
null
;
DeliveryOrder_
.
checkCertificate
,
DeliveryOrder_
.
checkHandover
,
DeliveryOrder_
.
checkKey
,
DeliveryOrder_
.
checkIdCard
,
DeliveryOrder_
.
vouchers
);
deliveryOrderDb
.
setOrderState
(
DeliveryOrder
.
OrderState
.
DELIVERED
);
return
deliveryOrderDb
;
}
}
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
...
@@ -106,14 +102,15 @@ public class DeliveryOrderService {
...
@@ -106,14 +102,15 @@ public class DeliveryOrderService {
return
deliveryOrderDb
;
return
deliveryOrderDb
;
}
}
/**
* 确认客户到店
*
* @deprecated 交付单功能已废弃,此方法始终返回 null
*/
@Deprecated
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
public
DeliveryOrder
confirmDeliveryOrderArrived
(
int
deliveryOrderId
)
{
public
DeliveryOrder
confirmDeliveryOrderArrived
(
int
deliveryOrderId
)
{
DeliveryOrder
deliveryOrderDb
=
deliveryOrderDao
.
findById
(
deliveryOrderId
).
orElseThrow
();
return
null
;
if
(
deliveryOrderDb
.
getOrderStatus
()
==
0
)
{
deliveryOrderDb
.
setOrderStatus
(
1
);
deliveryOrderDb
.
setStatusText
(
"客户到店"
);
}
return
deliveryOrderDb
;
}
}
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
...
@@ -158,4 +155,4 @@ public class DeliveryOrderService {
...
@@ -158,4 +155,4 @@ public class DeliveryOrderService {
public
long
countByVenueIdAndOrderState
(
int
venueId
,
DeliveryOrder
.
OrderState
orderState
)
{
public
long
countByVenueIdAndOrderState
(
int
venueId
,
DeliveryOrder
.
OrderState
orderState
)
{
return
deliveryOrderDao
.
countByAuctionOrder_Vehicle_Venue_VenueIdAndOrderState
(
venueId
,
orderState
);
return
deliveryOrderDao
.
countByAuctionOrder_Vehicle_Venue_VenueIdAndOrderState
(
venueId
,
orderState
);
}
}
}
\ No newline at end of file
\ No newline at end of file
}
aus-core/src/main/java/com/glsx/usedcar/module/business/entity/Agreement.java
View file @
7dffb96
...
@@ -144,6 +144,15 @@ public class Agreement extends AuditingEntity implements Serializable {
...
@@ -144,6 +144,15 @@ public class Agreement extends AuditingEntity implements Serializable {
*/
*/
COUPON_5
,
COUPON_5
,
/**
* 购车合同
*/
PURCHASE_CONTRACT
,
/**
* 平台交易整体合同
*/
PLATFORM_CONTRACT
,
;
;
}
}
...
...
aus-core/src/main/java/com/glsx/usedcar/module/business/service/AgreementService.java
View file @
7dffb96
...
@@ -10,6 +10,7 @@ import org.springframework.transaction.annotation.Propagation;
...
@@ -10,6 +10,7 @@ import org.springframework.transaction.annotation.Propagation;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.summerframework.orm.paging.Pagination
;
import
org.summerframework.orm.paging.Pagination
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.Optional
;
...
@@ -26,6 +27,16 @@ public class AgreementService {
...
@@ -26,6 +27,16 @@ public class AgreementService {
private
AgreementDao
agreementDao
;
private
AgreementDao
agreementDao
;
/**
/**
* 登录页需要展示的协议类型列表
*/
private
static
final
List
<
Agreement
.
AgreementKey
>
LOGIN_AGREEMENT_KEYS
=
List
.
of
(
Agreement
.
AgreementKey
.
ACCOUNT
,
// 用户协议
Agreement
.
AgreementKey
.
PRIVACY
,
// 隐私协议
Agreement
.
AgreementKey
.
PURCHASE_CONTRACT
,
// 购车合同
Agreement
.
AgreementKey
.
AUCTION
// 竞拍规则
);
/**
* 通过ID查询一个协议管理
* 通过ID查询一个协议管理
*
*
* @param agreementId 主键
* @param agreementId 主键
...
@@ -53,6 +64,34 @@ public class AgreementService {
...
@@ -53,6 +64,34 @@ public class AgreementService {
}
}
/**
/**
* 获取登录页需要展示的协议列表
* <p>
* 返回用户协议、隐私协议、购车合同、竞拍规则
* </p>
*
* @return 协议列表
*/
public
List
<
Agreement
>
getLoginAgreements
()
{
List
<
Agreement
>
agreements
=
new
ArrayList
<>();
for
(
Agreement
.
AgreementKey
key
:
LOGIN_AGREEMENT_KEYS
)
{
Agreement
agreement
=
getAgreementByKey
(
key
);
if
(
agreement
!=
null
)
{
agreements
.
add
(
agreement
);
}
}
return
agreements
;
}
/**
* 获取车商认证页需要展示的平台交易整体合同
*
* @return 平台交易整体合同
*/
public
Agreement
getPlatformContractAgreement
()
{
return
getAgreementByKey
(
Agreement
.
AgreementKey
.
PLATFORM_CONTRACT
);
}
/**
* 创建协议管理
* 创建协议管理
*
*
* @param agreement 协议管理实例对象
* @param agreement 协议管理实例对象
...
...
aus-core/src/main/java/com/glsx/usedcar/module/vehicle/entity/TransferMaterials.java
0 → 100644
View file @
7dffb96
package
com
.
glsx
.
usedcar
.
module
.
vehicle
.
entity
;
import
jakarta.persistence.Column
;
import
jakarta.persistence.Embeddable
;
import
lombok.Getter
;
import
lombok.Setter
;
import
java.io.Serial
;
import
java.io.Serializable
;
/**
* 过户资料勾选信息
* <p>
* 封装车辆过户所需资料的勾选状态,用于确认提车时展示随车资料信息
* </p>
* <p>
* 字段命名规范:
* <ul>
* <li>Java 字段名使用 lowerCamelCase(如 registrationCertificate)</li>
* <li>数据库字段名使用 has_ 前缀(如 has_registration_certificate),遵循阿里规范</li>
* <li>布尔类型使用 TINYINT(1) UNSIGNED,表示"是/否"概念</li>
* </ul>
* </p>
*/
@Embeddable
@Getter
@Setter
public
class
TransferMaterials
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
1L
;
/**
* 机动车登记本(大绿本)
* 1-有, 0-无
*/
@Column
(
name
=
"has_registration_certificate"
,
nullable
=
false
,
columnDefinition
=
"TINYINT(1) UNSIGNED DEFAULT 0"
)
private
boolean
registrationCertificate
=
false
;
/**
* 机动车行驶证
* 1-有, 0-无
*/
@Column
(
name
=
"has_vehicle_license"
,
nullable
=
false
,
columnDefinition
=
"TINYINT(1) UNSIGNED DEFAULT 0"
)
private
boolean
vehicleLicense
=
false
;
/**
* 交管12123截图
* 1-有, 0-无
*/
@Column
(
name
=
"has_traffic_app_screenshot"
,
nullable
=
false
,
columnDefinition
=
"TINYINT(1) UNSIGNED DEFAULT 0"
)
private
boolean
trafficAppScreenshot
=
false
;
/**
* 车钥匙套数
*/
@Column
(
name
=
"car_key_count"
,
nullable
=
false
,
columnDefinition
=
"TINYINT UNSIGNED DEFAULT 0"
)
private
int
carKeyCount
=
0
;
/**
* 交强险
* 1-有, 0-无
*/
@Column
(
name
=
"has_compulsory_insurance"
,
nullable
=
false
,
columnDefinition
=
"TINYINT(1) UNSIGNED DEFAULT 0"
)
private
boolean
compulsoryInsurance
=
false
;
/**
* 过户授权委托书照片
* 1-有, 0-无
*/
@Column
(
name
=
"has_transfer_authorization_photo"
,
nullable
=
false
,
columnDefinition
=
"TINYINT(1) UNSIGNED DEFAULT 0"
)
private
boolean
transferAuthorizationPhoto
=
false
;
/**
* 购置税证及收据
* 1-有, 0-无
*/
@Column
(
name
=
"has_purchase_tax_receipt"
,
nullable
=
false
,
columnDefinition
=
"TINYINT(1) UNSIGNED DEFAULT 0"
)
private
boolean
purchaseTaxReceipt
=
false
;
/**
* 购车发票
* 1-有, 0-无
*/
@Column
(
name
=
"has_purchase_invoice"
,
nullable
=
false
,
columnDefinition
=
"TINYINT(1) UNSIGNED DEFAULT 0"
)
private
boolean
purchaseInvoice
=
false
;
/**
* 商业保险单或卡
* 1-有, 0-无
*/
@Column
(
name
=
"has_commercial_insurance"
,
nullable
=
false
,
columnDefinition
=
"TINYINT(1) UNSIGNED DEFAULT 0"
)
private
boolean
commercialInsurance
=
false
;
/**
* 其他资料
* 1-有, 0-无
*/
@Column
(
name
=
"has_other_materials"
,
nullable
=
false
,
columnDefinition
=
"TINYINT(1) UNSIGNED DEFAULT 0"
)
private
boolean
otherMaterials
=
false
;
/**
* 其他资料说明
*/
@Column
(
name
=
"other_materials_note"
,
length
=
500
)
private
String
otherMaterialsNote
;
}
aus-core/src/main/java/com/glsx/usedcar/module/vehicle/entity/Vehicle.java
View file @
7dffb96
...
@@ -109,6 +109,12 @@ public class Vehicle extends AuditingEntity implements Serializable {
...
@@ -109,6 +109,12 @@ public class Vehicle extends AuditingEntity implements Serializable {
private
OwnerInfo
ownerInfo
;
private
OwnerInfo
ownerInfo
;
/**
/**
* 过户资料勾选信息
*/
@Embedded
private
TransferMaterials
transferMaterials
;
/**
* 车型数据json,
* 车型数据json,
* json字段参考查博士文档https://doc.chaboshi.cn/web/shareDoc/f98cbf2e13c37f7fd39ccdaf2b61a295
* json字段参考查博士文档https://doc.chaboshi.cn/web/shareDoc/f98cbf2e13c37f7fd39ccdaf2b61a295
*/
*/
...
@@ -116,6 +122,13 @@ public class Vehicle extends AuditingEntity implements Serializable {
...
@@ -116,6 +122,13 @@ public class Vehicle extends AuditingEntity implements Serializable {
private
String
carModelData
;
private
String
carModelData
;
/**
/**
* 过户资料JSON(从收车端推送,用于解析到 TransferMaterials)
* 不持久化到数据库
*/
@Transient
private
String
electronicContractField
;
/**
* 车辆所属场地
* 车辆所属场地
*/
*/
@CachedProperty
(
"Venue"
)
@CachedProperty
(
"Venue"
)
...
@@ -360,8 +373,10 @@ public class Vehicle extends AuditingEntity implements Serializable {
...
@@ -360,8 +373,10 @@ public class Vehicle extends AuditingEntity implements Serializable {
*/
*/
AUCTIONING
,
AUCTIONING
,
/**
/**
* 待签署合同
* 待签署合同(已废弃,历史数据已迁移为 UNPAID)
* @deprecated 使用 UNPAID 代替
*/
*/
@Deprecated
CONTRACT_UNSIGNED
,
CONTRACT_UNSIGNED
,
/**
/**
* 待付车款
* 待付车款
...
...
aus-core/src/main/java/com/glsx/usedcar/module/vehicle/service/VehicleService.java
View file @
7dffb96
package
com
.
glsx
.
usedcar
.
module
.
vehicle
.
service
;
package
com
.
glsx
.
usedcar
.
module
.
vehicle
.
service
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
com.glsx.usedcar.consts.inspect.JpaQueryConstants
;
import
com.glsx.usedcar.consts.inspect.JpaQueryConstants
;
import
com.glsx.usedcar.enums.common.DeleteFlag
;
import
com.glsx.usedcar.enums.common.DeleteFlag
;
import
com.glsx.usedcar.enums.inspect.InspectionWorkOrderStatusEnum
;
import
com.glsx.usedcar.enums.inspect.InspectionWorkOrderStatusEnum
;
...
@@ -12,15 +13,23 @@ import com.glsx.usedcar.module.auction.entity.dto.LightPollingBidConfigDTO;
...
@@ -12,15 +13,23 @@ import com.glsx.usedcar.module.auction.entity.dto.LightPollingBidConfigDTO;
import
com.glsx.usedcar.module.inspect.dao.InspectionWorkOrderRepository
;
import
com.glsx.usedcar.module.inspect.dao.InspectionWorkOrderRepository
;
import
com.glsx.usedcar.module.vehicle.dao.VehicleDao
;
import
com.glsx.usedcar.module.vehicle.dao.VehicleDao
;
import
com.glsx.usedcar.module.vehicle.dao.VehicleHistoryDao
;
import
com.glsx.usedcar.module.vehicle.dao.VehicleHistoryDao
;
import
com.glsx.usedcar.module.vehicle.domain.*
;
import
com.glsx.usedcar.module.vehicle.domain.CarImage
;
import
com.glsx.usedcar.module.vehicle.domain.VehicleHistoryProjection
;
import
com.glsx.usedcar.module.vehicle.domain.VehicleVenue
;
import
com.glsx.usedcar.module.vehicle.entity.*
;
import
com.glsx.usedcar.module.vehicle.entity.*
;
import
com.glsx.usedcar.module.vehicle.vo.VehicleAutoBidVO
;
import
com.glsx.usedcar.module.vehicle.vo.VehicleAutoBidVO
;
import
com.glsx.usedcar.module.vehicle.vo.VehicleStateCountRespVO
;
import
com.glsx.usedcar.module.vehicle.vo.VehicleStateCountRespVO
;
import
com.glsx.usedcar.module.venue.dao.*
;
import
com.glsx.usedcar.module.venue.dao.AreaDao
;
import
com.glsx.usedcar.module.venue.entity.*
;
import
com.glsx.usedcar.module.venue.dao.VenueDao
;
import
com.glsx.usedcar.module.venue.dao.WarehousingDao
;
import
com.glsx.usedcar.module.venue.entity.Area
;
import
com.glsx.usedcar.module.venue.entity.Venue
;
import
com.glsx.usedcar.module.venue.entity.Warehousing
;
import
com.glsx.usedcar.module.vrsystem.dao.VrAuditRepository
;
import
com.glsx.usedcar.module.vrsystem.dao.VrAuditRepository
;
import
com.glsx.usedcar.module.vrsystem.dao.VrOrgRepository
;
import
com.glsx.usedcar.module.vrsystem.dao.VrOrgRepository
;
import
com.glsx.usedcar.module.vrsystem.entity.*
;
import
com.glsx.usedcar.module.vrsystem.entity.VrAudit
;
import
com.glsx.usedcar.module.vrsystem.entity.VrAudit_
;
import
com.glsx.usedcar.module.vrsystem.entity.VrOrg
;
import
com.glsx.usedcar.resp.BaseResp
;
import
com.glsx.usedcar.resp.BaseResp
;
import
com.glsx.usedcar.util.CoderGenerator
;
import
com.glsx.usedcar.util.CoderGenerator
;
import
jakarta.annotation.Resource
;
import
jakarta.annotation.Resource
;
...
@@ -39,7 +48,6 @@ import org.springframework.transaction.annotation.Propagation;
...
@@ -39,7 +48,6 @@ import org.springframework.transaction.annotation.Propagation;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
import
org.summerframework.orm.paging.Filter
;
import
org.summerframework.orm.paging.Operator
;
import
org.summerframework.orm.paging.Operator
;
import
org.summerframework.orm.paging.Pagination
;
import
org.summerframework.orm.paging.Pagination
;
import
org.summerframework.storage.domain.FileInfo
;
import
org.summerframework.storage.domain.FileInfo
;
...
@@ -299,12 +307,108 @@ public class VehicleService {
...
@@ -299,12 +307,108 @@ public class VehicleService {
vehicle
.
setVenue
(
venue
);
vehicle
.
setVenue
(
venue
);
}
}
}
}
// 解析过户资料字段(从收车端推送的 electronicContractField)
vehicle
.
setTransferMaterials
(
parseElectronicContractField
(
vehicle
.
getElectronicContractField
()));
return
vehicleDao
.
save
(
vehicle
);
return
vehicleDao
.
save
(
vehicle
);
}
else
{
}
else
{
return
null
;
return
null
;
}
}
}
}
/**
* 从收车端 electronicContractField 解析过户资料信息
* <p>
* 收车端传递的 electronicContractField JSON 格式示例:
* {
* "registrationCertificate": true,
* "vehicleLicense": true,
* "trafficAppScreenshot": false,
* "carKeyCount": 2,
* "compulsoryInsurance": true,
* "transferAuthorizationPhoto": true,
* "purchaseTaxReceipt": false,
* "purchaseInvoice": true,
* "commercialInsurance": false,
* "otherMaterials": false,
* "otherMaterialsNote": "备注说明"
* }
* </p>
*
* @param electronicContractField JSON 字符串
* @return TransferMaterials 对象
*/
public
TransferMaterials
parseElectronicContractField
(
String
electronicContractField
)
{
TransferMaterials
transferMaterials
=
new
TransferMaterials
();
if
(!
StringUtils
.
hasText
(
electronicContractField
))
{
return
transferMaterials
;
}
try
{
JSONObject
json
=
JSONUtil
.
parseObj
(
electronicContractField
);
if
(
json
.
containsKey
(
"registrationCertificate"
))
{
transferMaterials
.
setRegistrationCertificate
(
json
.
getBool
(
"registrationCertificate"
,
false
));
}
if
(
json
.
containsKey
(
"vehicleLicense"
))
{
transferMaterials
.
setVehicleLicense
(
json
.
getBool
(
"vehicleLicense"
,
false
));
}
if
(
json
.
containsKey
(
"trafficAppScreenshot"
))
{
transferMaterials
.
setTrafficAppScreenshot
(
json
.
getBool
(
"trafficAppScreenshot"
,
false
));
}
if
(
json
.
containsKey
(
"carKeyCount"
))
{
transferMaterials
.
setCarKeyCount
(
json
.
getInt
(
"carKeyCount"
,
0
));
}
if
(
json
.
containsKey
(
"compulsoryInsurance"
))
{
transferMaterials
.
setCompulsoryInsurance
(
json
.
getBool
(
"compulsoryInsurance"
,
false
));
}
if
(
json
.
containsKey
(
"transferAuthorizationPhoto"
))
{
transferMaterials
.
setTransferAuthorizationPhoto
(
json
.
getBool
(
"transferAuthorizationPhoto"
,
false
));
}
if
(
json
.
containsKey
(
"purchaseTaxReceipt"
))
{
transferMaterials
.
setPurchaseTaxReceipt
(
json
.
getBool
(
"purchaseTaxReceipt"
,
false
));
}
if
(
json
.
containsKey
(
"purchaseInvoice"
))
{
transferMaterials
.
setPurchaseInvoice
(
json
.
getBool
(
"purchaseInvoice"
,
false
));
}
if
(
json
.
containsKey
(
"commercialInsurance"
))
{
transferMaterials
.
setCommercialInsurance
(
json
.
getBool
(
"commercialInsurance"
,
false
));
}
if
(
json
.
containsKey
(
"otherMaterials"
))
{
transferMaterials
.
setOtherMaterials
(
json
.
getBool
(
"otherMaterials"
,
false
));
}
if
(
json
.
containsKey
(
"otherMaterialsNote"
))
{
transferMaterials
.
setOtherMaterialsNote
(
json
.
getStr
(
"otherMaterialsNote"
));
}
log
.
info
(
"解析 electronicContractField 成功: {}"
,
electronicContractField
);
}
catch
(
Exception
e
)
{
log
.
warn
(
"解析 electronicContractField 失败: {}"
,
electronicContractField
,
e
);
}
return
transferMaterials
;
}
/**
* 更新车辆过户资料信息(从收车端同步)
*
* @param vehicleId 车辆ID
* @param electronicContractField 过户资料JSON字符串
* @return 更新后的车辆
*/
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
public
Vehicle
updateTransferMaterials
(
int
vehicleId
,
String
electronicContractField
)
{
Vehicle
vehicle
=
vehicleDao
.
findById
(
vehicleId
)
.
orElseThrow
(()
->
new
ObjectNotFoundException
(
vehicleId
,
Vehicle
.
class
.
getSimpleName
()));
TransferMaterials
transferMaterials
=
parseElectronicContractField
(
electronicContractField
);
vehicle
.
setTransferMaterials
(
transferMaterials
);
return
vehicleDao
.
save
(
vehicle
);
}
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
public
Vehicle
addVehicle
(
Vehicle
vehicle
)
{
public
Vehicle
addVehicle
(
Vehicle
vehicle
)
{
vehicle
.
getBaseInfo
().
setSourceNo
(
CoderGenerator
.
generateSourceNO
());
vehicle
.
getBaseInfo
().
setSourceNo
(
CoderGenerator
.
generateSourceNO
());
...
...
aus-core/src/main/java/com/glsx/usedcar/module/vrsystem/service/VrAuditService.java
View file @
7dffb96
...
@@ -1167,6 +1167,10 @@ public class VrAuditService {
...
@@ -1167,6 +1167,10 @@ public class VrAuditService {
ownerInfo
.
setPreviousOwnerPhone
(
""
);
// 车主联系方式,默认空
ownerInfo
.
setPreviousOwnerPhone
(
""
);
// 车主联系方式,默认空
vehicle
.
setOwnerInfo
(
ownerInfo
);
vehicle
.
setOwnerInfo
(
ownerInfo
);
// 设置过户资料勾选信息 TransferMaterials(默认值:全部为"无"或0)
TransferMaterials
transferMaterials
=
new
TransferMaterials
();
vehicle
.
setTransferMaterials
(
transferMaterials
);
// 设置车辆图片 carImages
// 设置车辆图片 carImages
List
<
CarImage
>
carImages
=
buildCarImages
(
vrAudit
);
List
<
CarImage
>
carImages
=
buildCarImages
(
vrAudit
);
vehicle
.
setCarImages
(
carImages
);
vehicle
.
setCarImages
(
carImages
);
...
...
aus-task/src/main/java/com/glsx/usedcar/task/TransferMaterialsSyncSchedule.java
0 → 100644
View file @
7dffb96
package
com
.
glsx
.
usedcar
.
task
;
import
com.glsx.usedcar.gsc.ReceiveClient
;
import
com.glsx.usedcar.module.vehicle.dao.VehicleDao
;
import
com.glsx.usedcar.module.vehicle.entity.Vehicle
;
import
com.glsx.usedcar.module.vehicle.entity.Vehicle_
;
import
com.glsx.usedcar.module.vehicle.service.VehicleService
;
import
jakarta.annotation.Resource
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
/**
* 过户资料同步定时任务
* <p>
* 从收车端同步存量车辆的过户资料(electronicContractField)数据
* </p>
*/
@Slf4j
@Component
public
class
TransferMaterialsSyncSchedule
{
@Resource
private
VehicleDao
vehicleDao
;
@Resource
private
VehicleService
vehicleService
;
@Resource
private
ReceiveClient
receiveClient
;
/**
* 每批次处理数量
*/
private
static
final
int
BATCH_SIZE
=
100
;
/**
* 定时同步过户资料
* <p>
* 每小时执行一次,同步收车端来源的车辆过户资料
* </p>
*/
@Scheduled
(
fixedDelay
=
1000
*
60
*
60
,
initialDelay
=
1000
*
60
*
5
)
public
void
syncTransferMaterials
()
{
log
.
info
(
"开始执行过户资料同步定时任务"
);
int
totalSynced
=
0
;
int
totalFailed
=
0
;
// 分页查询收车端来源的车辆
int
page
=
0
;
Page
<
Vehicle
>
vehiclePage
;
do
{
Specification
<
Vehicle
>
spec
=
(
root
,
query
,
cb
)
->
cb
.
equal
(
root
.
get
(
Vehicle_
.
vehicleSource
),
Vehicle
.
VehicleSource
.
RECEIVE
);
vehiclePage
=
vehicleDao
.
findAll
(
spec
,
PageRequest
.
of
(
page
,
BATCH_SIZE
));
if
(
vehiclePage
.
hasContent
())
{
List
<
Vehicle
>
vehicles
=
vehiclePage
.
getContent
();
List
<
String
>
sourceNos
=
new
ArrayList
<>();
// 收集车源号
for
(
Vehicle
vehicle
:
vehicles
)
{
if
(
vehicle
.
getBaseInfo
()
!=
null
&&
vehicle
.
getBaseInfo
().
getSourceNo
()
!=
null
)
{
sourceNos
.
add
(
vehicle
.
getBaseInfo
().
getSourceNo
());
}
}
if
(!
sourceNos
.
isEmpty
())
{
try
{
// 批量查询过户资料
Map
<
String
,
String
>
electronicContractFieldMap
=
receiveClient
.
batchQueryElectronicContractField
(
sourceNos
);
// 更新车辆过户资料
for
(
Vehicle
vehicle
:
vehicles
)
{
String
sourceNo
=
vehicle
.
getBaseInfo
().
getSourceNo
();
String
electronicContractField
=
electronicContractFieldMap
.
get
(
sourceNo
);
if
(
electronicContractField
!=
null
&&
!
electronicContractField
.
isEmpty
())
{
try
{
vehicleService
.
updateTransferMaterials
(
vehicle
.
getVehicleId
(),
electronicContractField
);
totalSynced
++;
}
catch
(
Exception
e
)
{
log
.
error
(
"更新车辆过户资料失败, vehicleId: {}"
,
vehicle
.
getVehicleId
(),
e
);
totalFailed
++;
}
}
}
}
catch
(
Exception
e
)
{
log
.
error
(
"批次 {} 查询过户资料失败"
,
page
,
e
);
totalFailed
+=
vehicles
.
size
();
}
}
}
page
++;
}
while
(
vehiclePage
.
hasNext
());
log
.
info
(
"过户资料同步定时任务完成,成功: {}, 失败: {}"
,
totalSynced
,
totalFailed
);
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment