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 c861af7b
authored
Mar 09, 2026
by
章家宝
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix:明拍新增轮询出价模式联调bug修复
1 parent
b6ac2787
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
139 additions
and
36 deletions
aus-admin/src/main/java/com/glsx/usedcar/web/rest/auction/BidController.java
aus-api/src/main/java/com/glsx/usedcar/web/api/business/ConfigController.java
aus-core/src/main/java/com/glsx/usedcar/module/auction/entity/dto/LightPollingBidConfigDTO.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/AuctionService.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/LightAuctionPoollingBidService.java
aus-core/src/main/java/com/glsx/usedcar/module/vehicle/entity/vo/VehicleAutoBidVO.java
aus-core/src/main/java/com/glsx/usedcar/module/vehicle/service/VehicleService.java
aus-admin/src/main/java/com/glsx/usedcar/web/rest/auction/BidController.java
View file @
c861af7
...
@@ -98,6 +98,9 @@ public class BidController {
...
@@ -98,6 +98,9 @@ public class BidController {
@PostMapping
(
"addBid"
)
@PostMapping
(
"addBid"
)
public
BaseResp
<
Bid
>
addBid
(
@Valid
@RequestBody
BidAddVO
bidAddVO
,
Authentication
authentication
)
throws
FieldException
{
public
BaseResp
<
Bid
>
addBid
(
@Valid
@RequestBody
BidAddVO
bidAddVO
,
Authentication
authentication
)
throws
FieldException
{
User
user
=
(
User
)
authentication
.
getPrincipal
();
User
user
=
(
User
)
authentication
.
getPrincipal
();
if
(
user
==
null
||
user
.
getUserId
()
<=
0
)
{
return
BaseResp
.
fail
(
"用户不存在"
);
}
return
BaseResp
.
success
(
bidService
.
addBidByAdmin
(
user
,
bidAddVO
));
return
BaseResp
.
success
(
bidService
.
addBidByAdmin
(
user
,
bidAddVO
));
}
}
...
...
aus-api/src/main/java/com/glsx/usedcar/web/api/business/ConfigController.java
View file @
c861af7
package
com
.
glsx
.
usedcar
.
web
.
api
.
business
;
package
com
.
glsx
.
usedcar
.
web
.
api
.
business
;
import
com.glsx.usedcar.esign.ESignPartAConfig
;
import
com.glsx.usedcar.module.business.domain.*
;
import
com.glsx.usedcar.module.business.domain.BusinessConfig
;
import
com.glsx.usedcar.module.business.domain.DarkBidPriceRange
;
import
com.glsx.usedcar.module.business.domain.LightBidPriceRange
;
import
jakarta.annotation.Resource
;
import
jakarta.annotation.Resource
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
...
...
aus-core/src/main/java/com/glsx/usedcar/module/auction/entity/dto/LightPollingBidConfigDTO.java
View file @
c861af7
package
com
.
glsx
.
usedcar
.
module
.
auction
.
entity
.
dto
;
package
com
.
glsx
.
usedcar
.
module
.
auction
.
entity
.
dto
;
import
com.alibaba.fastjson.JSON
;
import
lombok.*
;
import
lombok.*
;
/**
/**
...
@@ -20,4 +21,15 @@ public class LightPollingBidConfigDTO {
...
@@ -20,4 +21,15 @@ public class LightPollingBidConfigDTO {
private
Integer
resetDelayDuration
;
private
Integer
resetDelayDuration
;
// 车辆拍卖持续时间
// 车辆拍卖持续时间
private
Integer
aucvehDuration
;
private
Integer
aucvehDuration
;
// 拍卖车辆之间间隔时间
private
Integer
bidAucVehDuration
;
public
static
LightPollingBidConfigDTO
fromJson
(
String
extraJson
)
{
return
JSON
.
parseObject
(
extraJson
,
LightPollingBidConfigDTO
.
class
);
}
public
boolean
isValid
()
{
return
delay
!=
null
&&
nearReservePriceThreshold
!=
null
&&
resetDelay
!=
null
&&
resetDelayDuration
!=
null
&&
aucvehDuration
!=
null
&&
bidAucVehDuration
!=
null
;
}
}
}
aus-core/src/main/java/com/glsx/usedcar/module/auction/service/AuctionOrderService.java
View file @
c861af7
...
@@ -382,7 +382,10 @@ public class AuctionOrderService extends AbstractAuctionService {
...
@@ -382,7 +382,10 @@ public class AuctionOrderService extends AbstractAuctionService {
AuctionVehicle
auctionVehicle
=
auctionVehicleDao
.
findTopByAucvehId
(
aucvehId
);
AuctionVehicle
auctionVehicle
=
auctionVehicleDao
.
findTopByAucvehId
(
aucvehId
);
Bid
bid
=
bidDao
.
findTopByAuctionVehicleOrderByBidPriceDesc
(
auctionVehicle
);
Bid
bid
=
bidDao
.
findTopByAuctionVehicleOrderByBidPriceDesc
(
auctionVehicle
);
if
(
bid
==
null
)
{
if
(
bid
==
null
)
{
return
0
;
Vehicle
vehicle
=
auctionVehicle
.
getVehicle
();
double
startingBidPrice
=
vehicle
.
getStartingBidPrice
();
bid
=
new
Bid
();
bid
.
setBidPrice
(
startingBidPrice
);
}
}
bid
.
setAccount
(
account
);
bid
.
setAccount
(
account
);
return
calculateCommissionPrice
(
LocalDateTime
.
now
(),
bid
);
return
calculateCommissionPrice
(
LocalDateTime
.
now
(),
bid
);
...
...
aus-core/src/main/java/com/glsx/usedcar/module/auction/service/AuctionService.java
View file @
c861af7
...
@@ -13,6 +13,7 @@ import com.glsx.usedcar.module.auction.entity.*;
...
@@ -13,6 +13,7 @@ import com.glsx.usedcar.module.auction.entity.*;
import
com.glsx.usedcar.module.auction.entity.Auction.AuctionType
;
import
com.glsx.usedcar.module.auction.entity.Auction.AuctionType
;
import
com.glsx.usedcar.module.auction.entity.AuctionVehicle.AuctionState
;
import
com.glsx.usedcar.module.auction.entity.AuctionVehicle.AuctionState
;
import
com.glsx.usedcar.module.auction.entity.dto.BidRemainSecondDTO
;
import
com.glsx.usedcar.module.auction.entity.dto.BidRemainSecondDTO
;
import
com.glsx.usedcar.module.auction.entity.dto.LightPollingBidConfigDTO
;
import
com.glsx.usedcar.module.auction.entity.req.BidRemainSecReq
;
import
com.glsx.usedcar.module.auction.entity.req.BidRemainSecReq
;
import
com.glsx.usedcar.module.business.entity.NoticeTemplate
;
import
com.glsx.usedcar.module.business.entity.NoticeTemplate
;
import
com.glsx.usedcar.module.business.service.NoticeField
;
import
com.glsx.usedcar.module.business.service.NoticeField
;
...
@@ -31,6 +32,7 @@ import com.glsx.usedcar.resp.BaseResp;
...
@@ -31,6 +32,7 @@ import com.glsx.usedcar.resp.BaseResp;
import
com.glsx.usedcar.util.RedisCacheUtil
;
import
com.glsx.usedcar.util.RedisCacheUtil
;
import
jakarta.annotation.Resource
;
import
jakarta.annotation.Resource
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.hibernate.ObjectNotFoundException
;
import
org.hibernate.ObjectNotFoundException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.MessageSource
;
import
org.springframework.context.MessageSource
;
...
@@ -46,6 +48,7 @@ import org.summerframework.core.util.DateTimeUtils;
...
@@ -46,6 +48,7 @@ import org.summerframework.core.util.DateTimeUtils;
import
org.summerframework.orm.paging.Pagination
;
import
org.summerframework.orm.paging.Pagination
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.time.Duration
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
...
@@ -141,6 +144,7 @@ public class AuctionService extends AbstractAuctionService {
...
@@ -141,6 +144,7 @@ public class AuctionService extends AbstractAuctionService {
String
join
=
String
.
join
(
","
,
sourceNos
);
String
join
=
String
.
join
(
","
,
sourceNos
);
throw
new
FieldException
(
"sourceNos"
,
sourceNos
,
"车源号:"
+
join
+
"的车辆状态不是待关联拍卖状态,请重新选择车辆"
);
throw
new
FieldException
(
"sourceNos"
,
sourceNos
,
"车源号:"
+
join
+
"的车辆状态不是待关联拍卖状态,请重新选择车辆"
);
}
}
checkAuctionConfig
(
auction
,
auctionVehicles
);
auction
.
setAccessScope
(
CollectionUtils
.
isEmpty
(
auction
.
getAccountTags
())
?
Auction
.
AccessScope
.
GLOBAL
:
Auction
.
AccessScope
.
TAGS
);
auction
.
setAccessScope
(
CollectionUtils
.
isEmpty
(
auction
.
getAccountTags
())
?
Auction
.
AccessScope
.
GLOBAL
:
Auction
.
AccessScope
.
TAGS
);
if
(!
CollectionUtils
.
isEmpty
(
auction
.
getAccountTags
()))
{
if
(!
CollectionUtils
.
isEmpty
(
auction
.
getAccountTags
()))
{
auction
.
setAccountTags
(
new
HashSet
<>(
accountTagDao
.
findByEntityIds
(
auction
.
getAccountTags
())));
auction
.
setAccountTags
(
new
HashSet
<>(
accountTagDao
.
findByEntityIds
(
auction
.
getAccountTags
())));
...
@@ -164,6 +168,44 @@ public class AuctionService extends AbstractAuctionService {
...
@@ -164,6 +168,44 @@ public class AuctionService extends AbstractAuctionService {
}
}
/**
/**
* 检查拍场配置
*/
private
static
void
checkAuctionConfig
(
Auction
auction
,
List
<
AuctionVehicle
>
auctionVehicles
)
throws
FieldException
{
if
(
auction
.
getAuctionType
()
==
AuctionType
.
LIGHT
&&
auction
.
getAuctionMode
()
==
2
)
{
// 明拍, 轮询出价
// 获取所有拍卖车辆的最低保留价
double
minReservePrice
=
Double
.
MAX_VALUE
;
for
(
AuctionVehicle
auctionVehicle
:
auctionVehicles
)
{
Vehicle
vehicle
=
auctionVehicle
.
getVehicle
();
minReservePrice
=
Math
.
min
(
minReservePrice
,
vehicle
.
getReservePrice
());
}
String
extraJson
=
auction
.
getExtraJson
();
if
(
StringUtils
.
isBlank
(
extraJson
))
{
throw
new
FieldException
(
"extraJson"
,
"请填写轮询出价参数"
);
}
LightPollingBidConfigDTO
dto
=
LightPollingBidConfigDTO
.
fromJson
(
extraJson
);
if
(!
dto
.
isValid
())
{
log
.
info
(
"轮询出价配置错误{}"
,
extraJson
);
throw
new
FieldException
(
"extraJson"
,
"明拍竞价配置错误"
);
}
Integer
nearReservePriceThreshold
=
dto
.
getNearReservePriceThreshold
();
if
(
nearReservePriceThreshold
<
0
||
nearReservePriceThreshold
>
minReservePrice
)
{
log
.
info
(
"nearReservePriceThreshold:{} < minReservePrice:{}"
,
nearReservePriceThreshold
,
minReservePrice
);
throw
new
FieldException
(
"extraJson"
,
"设定的保留价提醒阈值:最小0,最大不超过当前拍场中车辆的最低价保留价"
);
}
// 重置延时:最小值为0,最大值小于等于拍卖持续时间。
Integer
resetDelay
=
dto
.
getResetDelay
();
// 拍场持续时间
Duration
duration
=
Duration
.
between
(
auction
.
getAuctionStartTime
(),
auction
.
getAuctionEndTime
());
long
secondsDiff
=
duration
.
getSeconds
();
if
(
resetDelay
<
0
||
resetDelay
>
secondsDiff
)
{
log
.
info
(
"重置延时:最小0,最大小于等于拍卖持续时间 resetDelay:{} < 0 or > secondsDiff:{}"
,
resetDelay
,
secondsDiff
);
throw
new
FieldException
(
"extraJson"
,
"重置延时:最小0,最大小于等于拍卖持续时间"
);
}
}
}
/**
* 修改拍卖场次
* 修改拍卖场次
*
*
* @param auction 拍卖场次实例对象
* @param auction 拍卖场次实例对象
...
@@ -178,6 +220,7 @@ public class AuctionService extends AbstractAuctionService {
...
@@ -178,6 +220,7 @@ public class AuctionService extends AbstractAuctionService {
if
(
auction
.
getAuctionMode
()
!=
2
)
{
if
(
auction
.
getAuctionMode
()
!=
2
)
{
auction
.
setExtraJson
(
null
);
auction
.
setExtraJson
(
null
);
}
}
checkAuctionConfig
(
auction
,
auctionVehicles
);
Auction
auctionDb
=
auctionDao
.
updateById
(
auction
,
Auction_
.
auctionName
,
Auction_
.
user
,
Auction_
.
previewStartTime
,
Auction_
.
auctionStartTime
,
Auction_
.
auctionEndTime
,
Auction_
.
deposit
,
Auction_
.
auctionType
,
Auction_
.
beforeEndMinute
,
Auction_
.
delayMinute
,
Auction_
.
cities
,
Auction_
.
remark
,
Auction_
.
extraJson
,
Auction_
.
auctionMode
);
Auction
auctionDb
=
auctionDao
.
updateById
(
auction
,
Auction_
.
auctionName
,
Auction_
.
user
,
Auction_
.
previewStartTime
,
Auction_
.
auctionStartTime
,
Auction_
.
auctionEndTime
,
Auction_
.
deposit
,
Auction_
.
auctionType
,
Auction_
.
beforeEndMinute
,
Auction_
.
delayMinute
,
Auction_
.
cities
,
Auction_
.
remark
,
Auction_
.
extraJson
,
Auction_
.
auctionMode
);
auctionDb
.
setAuctionDate
(
auctionDb
.
getAuctionStartTime
().
toLocalDate
());
auctionDb
.
setAuctionDate
(
auctionDb
.
getAuctionStartTime
().
toLocalDate
());
...
@@ -268,6 +311,9 @@ public class AuctionService extends AbstractAuctionService {
...
@@ -268,6 +311,9 @@ public class AuctionService extends AbstractAuctionService {
}
}
}
}
auctionVehicleDao
.
save
(
av
);
auctionVehicleDao
.
save
(
av
);
if
(
auction
.
getAuctionType
()
==
AuctionType
.
LIGHT
&&
auction
.
getAuctionMode
()
==
2
)
{
lightAuctionPoollingBidService
.
addVehicle
(
av
,
auction
);
}
}
}
auction
.
setVehicleCount
((
int
)
auctionVehicleDao
.
countByAuction
(
auction
));
auction
.
setVehicleCount
((
int
)
auctionVehicleDao
.
countByAuction
(
auction
));
}
}
...
...
aus-core/src/main/java/com/glsx/usedcar/module/auction/service/BidService.java
View file @
c861af7
...
@@ -183,7 +183,7 @@ public class BidService {
...
@@ -183,7 +183,7 @@ public class BidService {
log
.
info
(
"{} {} {} 该车辆已结束竞标"
,
auctionVehicle
.
getAuction
().
getAuctionId
(),
aucvehId
,
auctionVehicle
.
getAuction
().
getAuctionName
());
log
.
info
(
"{} {} {} 该车辆已结束竞标"
,
auctionVehicle
.
getAuction
().
getAuctionId
(),
aucvehId
,
auctionVehicle
.
getAuction
().
getAuctionName
());
throw
new
FieldException
(
"aucvehId"
,
aucvehId
,
"该车辆已结束竞标"
);
throw
new
FieldException
(
"aucvehId"
,
aucvehId
,
"该车辆已结束竞标"
);
}
}
return
addBid
(
bidPrice
,
auctionVehicle
,
auctionVehicle
.
getAuction
(),
null
,
BidTypeEnum
.
BID_
ADMIN
,
null
);
return
addBid
(
bidPrice
,
auctionVehicle
,
auctionVehicle
.
getAuction
(),
null
,
BidTypeEnum
.
BID_
SYSTEM
,
null
);
}
}
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
...
...
aus-core/src/main/java/com/glsx/usedcar/module/auction/service/LightAuctionPoollingBidService.java
View file @
c861af7
...
@@ -119,10 +119,10 @@ public class LightAuctionPoollingBidService {
...
@@ -119,10 +119,10 @@ public class LightAuctionPoollingBidService {
}
}
long
curr
=
System
.
currentTimeMillis
();
long
curr
=
System
.
currentTimeMillis
();
long
millis
=
curr
+
d
*
60
*
1000L
+
aucvehDuration
*
1000L
;
long
millis
=
curr
+
d
*
60
*
1000L
+
aucvehDuration
*
1000L
;
redisCacheUtil
.
setCacheWithExpire
(
String
.
format
(
END_TIME_KEY
,
auctionVehicle
.
getAucvehId
()),
millis
,
3
,
TimeUnit
.
HOURS
);
redisCacheUtil
.
setCacheWithExpire
(
String
.
format
(
END_TIME_KEY
,
auctionVehicle
.
getAucvehId
()),
millis
,
24
,
TimeUnit
.
HOURS
);
// 起拍价
// 起拍价
double
startingBidPrice
=
auctionVehicle
.
getVehicle
().
getStartingBidPrice
();
double
startingBidPrice
=
auctionVehicle
.
getVehicle
().
getStartingBidPrice
();
redisCacheUtil
.
setCacheWithExpire
(
String
.
format
(
PRICE_KEY
,
auctionVehicle
.
getAucvehId
()),
BigDecimal
.
valueOf
(
startingBidPrice
),
3
,
TimeUnit
.
HOURS
);
redisCacheUtil
.
setCacheWithExpire
(
String
.
format
(
PRICE_KEY
,
auctionVehicle
.
getAucvehId
()),
BigDecimal
.
valueOf
(
startingBidPrice
),
24
,
TimeUnit
.
HOURS
);
auctionVehicle
.
setAuctionStartTime
(
LocalDateTimeUtil
.
milliToLocalDateTime
(
curr
));
auctionVehicle
.
setAuctionStartTime
(
LocalDateTimeUtil
.
milliToLocalDateTime
(
curr
));
auctionVehicle
.
setAuctionEndTime
(
LocalDateTimeUtil
.
milliToLocalDateTime
(
millis
));
auctionVehicle
.
setAuctionEndTime
(
LocalDateTimeUtil
.
milliToLocalDateTime
(
millis
));
auctionVehicleDao
.
updateById
(
auctionVehicle
,
AuctionVehicle_
.
auctionStartTime
,
AuctionVehicle_
.
auctionEndTime
);
auctionVehicleDao
.
updateById
(
auctionVehicle
,
AuctionVehicle_
.
auctionStartTime
,
AuctionVehicle_
.
auctionEndTime
);
...
@@ -132,7 +132,7 @@ public class LightAuctionPoollingBidService {
...
@@ -132,7 +132,7 @@ public class LightAuctionPoollingBidService {
auctionDao
.
updateById
(
auction
,
Auction_
.
auctionEndTime
);
auctionDao
.
updateById
(
auction
,
Auction_
.
auctionEndTime
);
}
}
// 明拍竞价 拍卖车辆间隔时间 秒
// 明拍竞价 拍卖车辆间隔时间 秒
int
lightPoolingBidAucVehDur
=
systemConfigRedisCache
.
getConfigValueAsInt
(
"light_pooling_bid_auc_veh_dur"
,
5
);
int
lightPoolingBidAucVehDur
=
lightPollingBidConfig
.
getBidAucVehDuration
(
);
long
nextAuctionVehicleStartTimeMillis
=
millis
+
lightPoolingBidAucVehDur
*
1000L
;
long
nextAuctionVehicleStartTimeMillis
=
millis
+
lightPoolingBidAucVehDur
*
1000L
;
// 更新下一辆车上场时间
// 更新下一辆车上场时间
redisCacheUtil
.
setCacheWithExpire
(
String
.
format
(
NEXT_AUCTION_VEHICLE_START_TIME_KEY
,
auction
.
getAuctionId
()),
nextAuctionVehicleStartTimeMillis
,
24
,
TimeUnit
.
HOURS
);
redisCacheUtil
.
setCacheWithExpire
(
String
.
format
(
NEXT_AUCTION_VEHICLE_START_TIME_KEY
,
auction
.
getAuctionId
()),
nextAuctionVehicleStartTimeMillis
,
24
,
TimeUnit
.
HOURS
);
...
@@ -161,11 +161,11 @@ public class LightAuctionPoollingBidService {
...
@@ -161,11 +161,11 @@ public class LightAuctionPoollingBidService {
}
}
log
.
info
(
"{} {} {} 该拍场使用轮询出价 {} "
,
auction
.
getAuctionId
(),
auction
.
getAuctionName
(),
extraJson
,
bid
.
getBidPrice
());
log
.
info
(
"{} {} {} 该拍场使用轮询出价 {} "
,
auction
.
getAuctionId
(),
auction
.
getAuctionName
(),
extraJson
,
bid
.
getBidPrice
());
// 出价时间缓存
// 出价时间缓存
redisCacheUtil
.
setCacheWithExpire
(
String
.
format
(
BID_TIME_KEY
,
auctionVehicle
.
getAucvehId
()),
System
.
currentTimeMillis
(),
3
,
TimeUnit
.
HOURS
);
redisCacheUtil
.
setCacheWithExpire
(
String
.
format
(
BID_TIME_KEY
,
auctionVehicle
.
getAucvehId
()),
System
.
currentTimeMillis
(),
24
,
TimeUnit
.
HOURS
);
processSignificantPriceIncrease
(
bid
,
auctionVehicle
.
getAucvehId
());
processSignificantPriceIncrease
(
bid
,
auctionVehicle
.
getAucvehId
());
LightPollingBidConfigDTO
lightPollingBidConfig
=
JSON
.
parseObject
(
extraJson
,
LightPollingBidConfigDTO
.
class
);
LightPollingBidConfigDTO
lightPollingBidConfig
=
JSON
.
parseObject
(
extraJson
,
LightPollingBidConfigDTO
.
class
);
// 更新价格
// 更新价格
redisCacheUtil
.
setCacheWithExpire
(
String
.
format
(
PRICE_KEY
,
auctionVehicle
.
getAucvehId
()),
BigDecimal
.
valueOf
(
bid
.
getBidPrice
()),
3
,
TimeUnit
.
HOURS
);
redisCacheUtil
.
setCacheWithExpire
(
String
.
format
(
PRICE_KEY
,
auctionVehicle
.
getAucvehId
()),
BigDecimal
.
valueOf
(
bid
.
getBidPrice
()),
24
,
TimeUnit
.
HOURS
);
// 接近保留价相关处理
// 接近保留价相关处理
nearReservePrice
(
bid
,
auctionVehicle
,
lightPollingBidConfig
);
nearReservePrice
(
bid
,
auctionVehicle
,
lightPollingBidConfig
);
resetAucVehEndTime
(
auctionVehicle
,
lightPollingBidConfig
);
resetAucVehEndTime
(
auctionVehicle
,
lightPollingBidConfig
);
...
@@ -177,7 +177,7 @@ public class LightAuctionPoollingBidService {
...
@@ -177,7 +177,7 @@ public class LightAuctionPoollingBidService {
private
void
saveAccountBidPrice
(
Bid
bid
,
int
aucvehId
)
{
private
void
saveAccountBidPrice
(
Bid
bid
,
int
aucvehId
)
{
int
accountId
=
bid
.
getAccount
()
==
null
?
0
:
bid
.
getAccount
().
getAccountId
();
int
accountId
=
bid
.
getAccount
()
==
null
?
0
:
bid
.
getAccount
().
getAccountId
();
String
key
=
String
.
format
(
ACCOUNT_BID_PRICE_KEY
,
aucvehId
,
accountId
);
String
key
=
String
.
format
(
ACCOUNT_BID_PRICE_KEY
,
aucvehId
,
accountId
);
redisCacheUtil
.
setCacheWithExpire
(
key
,
BigDecimal
.
valueOf
(
bid
.
getBidPrice
()),
3
,
TimeUnit
.
HOURS
);
redisCacheUtil
.
setCacheWithExpire
(
key
,
BigDecimal
.
valueOf
(
bid
.
getBidPrice
()),
24
,
TimeUnit
.
HOURS
);
}
}
private
BigDecimal
getAccountBidPrice
(
int
accountId
,
int
aucvehId
)
{
private
BigDecimal
getAccountBidPrice
(
int
accountId
,
int
aucvehId
)
{
...
@@ -212,7 +212,7 @@ public class LightAuctionPoollingBidService {
...
@@ -212,7 +212,7 @@ public class LightAuctionPoollingBidService {
return
;
return
;
}
}
// 重置时间
// 重置时间
redisCacheUtil
.
setCacheWithExpire
(
String
.
format
(
END_TIME_KEY
,
auctionVehicle
.
getAucvehId
()),
resetEndTime
,
3
,
TimeUnit
.
HOURS
);
redisCacheUtil
.
setCacheWithExpire
(
String
.
format
(
END_TIME_KEY
,
auctionVehicle
.
getAucvehId
()),
resetEndTime
,
24
,
TimeUnit
.
HOURS
);
auctionVehicle
.
setAuctionEndTime
(
LocalDateTimeUtil
.
milliToLocalDateTime
(
resetEndTime
));
auctionVehicle
.
setAuctionEndTime
(
LocalDateTimeUtil
.
milliToLocalDateTime
(
resetEndTime
));
auctionVehicleDao
.
updateById
(
auctionVehicle
,
AuctionVehicle_
.
auctionEndTime
);
auctionVehicleDao
.
updateById
(
auctionVehicle
,
AuctionVehicle_
.
auctionEndTime
);
// 拍场延长时间
// 拍场延长时间
...
@@ -222,7 +222,7 @@ public class LightAuctionPoollingBidService {
...
@@ -222,7 +222,7 @@ public class LightAuctionPoollingBidService {
auctionDao
.
updateById
(
auction
,
Auction_
.
auctionEndTime
);
auctionDao
.
updateById
(
auction
,
Auction_
.
auctionEndTime
);
}
}
// 明拍竞价 拍卖车辆间隔时间 秒
// 明拍竞价 拍卖车辆间隔时间 秒
int
lightPoolingBidAucVehDur
=
systemConfigRedisCache
.
getConfigValueAsInt
(
"light_pooling_bid_auc_veh_dur"
,
5
);
int
lightPoolingBidAucVehDur
=
lightPollingBidConfig
.
getBidAucVehDuration
(
);
long
nextAuctionVehicleStartTimeMillis
=
resetEndTime
+
lightPoolingBidAucVehDur
*
1000L
;
long
nextAuctionVehicleStartTimeMillis
=
resetEndTime
+
lightPoolingBidAucVehDur
*
1000L
;
// 更新下一辆车上场时间
// 更新下一辆车上场时间
redisCacheUtil
.
setCacheWithExpire
(
String
.
format
(
NEXT_AUCTION_VEHICLE_START_TIME_KEY
,
auction
.
getAuctionId
()),
nextAuctionVehicleStartTimeMillis
,
24
,
TimeUnit
.
HOURS
);
redisCacheUtil
.
setCacheWithExpire
(
String
.
format
(
NEXT_AUCTION_VEHICLE_START_TIME_KEY
,
auction
.
getAuctionId
()),
nextAuctionVehicleStartTimeMillis
,
24
,
TimeUnit
.
HOURS
);
...
@@ -235,7 +235,7 @@ public class LightAuctionPoollingBidService {
...
@@ -235,7 +235,7 @@ public class LightAuctionPoollingBidService {
// 保留价
// 保留价
double
reservePrice
=
auctionVehicle
.
getVehicle
().
getReservePrice
();
double
reservePrice
=
auctionVehicle
.
getVehicle
().
getReservePrice
();
if
(
bid
.
getBidPrice
()
>
reservePrice
)
{
if
(
bid
.
getBidPrice
()
>
reservePrice
)
{
redisCacheUtil
.
setCacheWithExpire
(
String
.
format
(
NEAR_RESERVE_PRICE_KEY
,
auctionVehicle
.
getAucvehId
()),
2
,
3
,
TimeUnit
.
HOURS
);
redisCacheUtil
.
setCacheWithExpire
(
String
.
format
(
NEAR_RESERVE_PRICE_KEY
,
auctionVehicle
.
getAucvehId
()),
2
,
24
,
TimeUnit
.
HOURS
);
return
;
return
;
}
}
// 保留价提醒价
// 保留价提醒价
...
@@ -246,7 +246,7 @@ public class LightAuctionPoollingBidService {
...
@@ -246,7 +246,7 @@ public class LightAuctionPoollingBidService {
}
}
if
(
bid
.
getBidPrice
()
>=
reservePrice
-
nearReservePriceThreshold
)
{
if
(
bid
.
getBidPrice
()
>=
reservePrice
-
nearReservePriceThreshold
)
{
// 接近保留价
// 接近保留价
redisCacheUtil
.
setCacheWithExpire
(
String
.
format
(
NEAR_RESERVE_PRICE_KEY
,
auctionVehicle
.
getAucvehId
()),
1
,
3
,
TimeUnit
.
HOURS
);
redisCacheUtil
.
setCacheWithExpire
(
String
.
format
(
NEAR_RESERVE_PRICE_KEY
,
auctionVehicle
.
getAucvehId
()),
1
,
24
,
TimeUnit
.
HOURS
);
}
}
}
}
...
@@ -265,7 +265,7 @@ public class LightAuctionPoollingBidService {
...
@@ -265,7 +265,7 @@ public class LightAuctionPoollingBidService {
return
;
return
;
}
}
log
.
info
(
"{} {} {} {} 大幅加价"
,
bid
,
bidPrice
,
auctionVehiclePrice
,
price
);
log
.
info
(
"{} {} {} {} 大幅加价"
,
bid
,
bidPrice
,
auctionVehiclePrice
,
price
);
redisCacheUtil
.
setCacheWithExpire
(
String
.
format
(
SIGNIFICANT_PRICE_INCREASE_STRING_REDIS_KEY
,
aucvehId
),
1
,
3
,
TimeUnit
.
HOURS
);
redisCacheUtil
.
setCacheWithExpire
(
String
.
format
(
SIGNIFICANT_PRICE_INCREASE_STRING_REDIS_KEY
,
aucvehId
),
1
,
24
,
TimeUnit
.
HOURS
);
redisCacheUtil
.
deleteCache
(
String
.
format
(
SIGNIFICANT_PRICE_INCREASE_ACCOUNT_REMINDER_LIST_REDIS_KEY
,
aucvehId
));
redisCacheUtil
.
deleteCache
(
String
.
format
(
SIGNIFICANT_PRICE_INCREASE_ACCOUNT_REMINDER_LIST_REDIS_KEY
,
aucvehId
));
}
}
...
@@ -424,7 +424,11 @@ public class LightAuctionPoollingBidService {
...
@@ -424,7 +424,11 @@ public class LightAuctionPoollingBidService {
// 判断是否达到了保留价,如果达到了保留价则不再加价
// 判断是否达到了保留价,如果达到了保留价则不再加价
double
reservePrice
=
auctionVehicle
.
getVehicle
().
getReservePrice
();
double
reservePrice
=
auctionVehicle
.
getVehicle
().
getReservePrice
();
BigDecimal
auctionVehiclePrice
=
getAuctionVehiclePrice
(
aucvehId
);
BigDecimal
auctionVehiclePrice
=
getAuctionVehiclePrice
(
aucvehId
);
if
(
auctionVehiclePrice
.
doubleValue
()
>=
reservePrice
)
{
if
(
autoBidRange
==
null
||
autoBidRange
<=
0
)
{
log
.
info
(
"自动出价幅度异常:拍卖车辆{} {}"
,
aucvehId
,
autoBidRange
);
return
;
}
if
(
auctionVehiclePrice
.
doubleValue
()
+
autoBidRange
>=
reservePrice
)
{
log
.
info
(
"拍卖车辆{}已达到保留价,不再加价"
,
aucvehId
);
log
.
info
(
"拍卖车辆{}已达到保留价,不再加价"
,
aucvehId
);
return
;
return
;
}
}
...
@@ -436,10 +440,6 @@ public class LightAuctionPoollingBidService {
...
@@ -436,10 +440,6 @@ public class LightAuctionPoollingBidService {
log
.
info
(
"自动出价触发价格异常:拍卖车辆{} {}"
,
aucvehId
,
autoBidTrigger
);
log
.
info
(
"自动出价触发价格异常:拍卖车辆{} {}"
,
aucvehId
,
autoBidTrigger
);
return
;
return
;
}
}
if
(
autoBidRange
==
null
||
autoBidRange
<=
0
)
{
log
.
info
(
"自动出价幅度异常:拍卖车辆{} {}"
,
aucvehId
,
autoBidRange
);
return
;
}
long
curr
=
System
.
currentTimeMillis
();
long
curr
=
System
.
currentTimeMillis
();
long
auctionVehicleEndTime
=
getAuctionVehicleEndTime
(
aucvehId
);
long
auctionVehicleEndTime
=
getAuctionVehicleEndTime
(
aucvehId
);
if
(
auctionVehicleEndTime
<=
0
||
auctionVehicleEndTime
-
curr
>
autoBidTrigger
.
longValue
()
*
1000
)
{
if
(
auctionVehicleEndTime
<=
0
||
auctionVehicleEndTime
-
curr
>
autoBidTrigger
.
longValue
()
*
1000
)
{
...
@@ -503,8 +503,8 @@ public class LightAuctionPoollingBidService {
...
@@ -503,8 +503,8 @@ public class LightAuctionPoollingBidService {
}
}
String
[]
split
=
orderStr
.
split
(
","
);
String
[]
split
=
orderStr
.
split
(
","
);
Integer
nextId
=
null
;
Integer
nextId
=
null
;
for
(
int
i
=
index
;
i
<
100000
;
i
++
)
{
while
(
index
<
split
.
length
)
{
String
s
=
split
[
i
];
String
s
=
split
[
i
ndex
];
int
id
=
Integer
.
parseInt
(
s
);
int
id
=
Integer
.
parseInt
(
s
);
AuctionVehicle
item
=
auctionVehicleDao
.
findTopByAucvehId
(
id
);
AuctionVehicle
item
=
auctionVehicleDao
.
findTopByAucvehId
(
id
);
index
++;
index
++;
...
@@ -513,7 +513,10 @@ public class LightAuctionPoollingBidService {
...
@@ -513,7 +513,10 @@ public class LightAuctionPoollingBidService {
break
;
break
;
}
}
}
}
double
remainSecond
=
(
nextAuctionVehicleStartTime
-
System
.
currentTimeMillis
())
/
1000
d
;
Double
remainSecond
=
null
;
if
(
nextId
!=
null
)
{
remainSecond
=
(
nextAuctionVehicleStartTime
-
System
.
currentTimeMillis
())
/
1000
d
;
}
result
.
setAucvehId
(
nextId
);
result
.
setAucvehId
(
nextId
);
result
.
setRemainSecond
(
remainSecond
);
result
.
setRemainSecond
(
remainSecond
);
return
result
;
return
result
;
...
@@ -531,8 +534,11 @@ public class LightAuctionPoollingBidService {
...
@@ -531,8 +534,11 @@ public class LightAuctionPoollingBidService {
long
resetEndTime
=
auctionVehicleEndTime
+
delay
*
60
*
1000L
;
long
resetEndTime
=
auctionVehicleEndTime
+
delay
*
60
*
1000L
;
// 重置时间
// 重置时间
redisCacheUtil
.
setCacheWithExpire
(
String
.
format
(
END_TIME_KEY
,
auctionVehicle
.
getAucvehId
()),
resetEndTime
,
24
,
TimeUnit
.
HOURS
);
redisCacheUtil
.
setCacheWithExpire
(
String
.
format
(
END_TIME_KEY
,
auctionVehicle
.
getAucvehId
()),
resetEndTime
,
24
,
TimeUnit
.
HOURS
);
Auction
auction
=
auctionVehicle
.
getAuction
();
String
extraJson
=
auction
.
getExtraJson
();
LightPollingBidConfigDTO
lightPollingBidConfigDTO
=
LightPollingBidConfigDTO
.
fromJson
(
extraJson
);
// 明拍竞价 拍卖车辆间隔时间 秒
// 明拍竞价 拍卖车辆间隔时间 秒
int
lightPoolingBidAucVehDur
=
systemConfigRedisCache
.
getConfigValueAsInt
(
"light_pooling_bid_auc_veh_dur"
,
5
);
int
lightPoolingBidAucVehDur
=
lightPollingBidConfigDTO
.
getBidAucVehDuration
(
);
long
nextAuctionVehicleStartTimeMillis
=
resetEndTime
+
lightPoolingBidAucVehDur
*
1000L
;
long
nextAuctionVehicleStartTimeMillis
=
resetEndTime
+
lightPoolingBidAucVehDur
*
1000L
;
// 更新下一辆车上场时间
// 更新下一辆车上场时间
redisCacheUtil
.
setCacheWithExpire
(
String
.
format
(
NEXT_AUCTION_VEHICLE_START_TIME_KEY
,
auctionVehicle
.
getAuction
().
getAuctionId
()),
nextAuctionVehicleStartTimeMillis
,
24
,
TimeUnit
.
HOURS
);
redisCacheUtil
.
setCacheWithExpire
(
String
.
format
(
NEXT_AUCTION_VEHICLE_START_TIME_KEY
,
auctionVehicle
.
getAuction
().
getAuctionId
()),
nextAuctionVehicleStartTimeMillis
,
24
,
TimeUnit
.
HOURS
);
...
@@ -544,7 +550,16 @@ public class LightAuctionPoollingBidService {
...
@@ -544,7 +550,16 @@ public class LightAuctionPoollingBidService {
d
=
delay
+
d
;
d
=
delay
+
d
;
redisCacheUtil
.
setCacheWithExpire
(
String
.
format
(
AUCTION_VEHICLE_DELAY_TIME_KEY
,
aucvehId
),
d
,
24
,
TimeUnit
.
HOURS
);
redisCacheUtil
.
setCacheWithExpire
(
String
.
format
(
AUCTION_VEHICLE_DELAY_TIME_KEY
,
aucvehId
),
d
,
24
,
TimeUnit
.
HOURS
);
}
}
}
/**
* 添加待拍卖车辆
*/
public
void
addVehicle
(
AuctionVehicle
av
,
Auction
auction
)
{
String
orderStr
=
redisCacheUtil
.
getCache
(
String
.
format
(
AUCTION_ORDER_KEY
,
auction
.
getAuctionId
()),
String
.
class
);
String
[]
list
=
orderStr
.
split
(
","
);
List
<
String
>
l
=
new
ArrayList
<>(
Arrays
.
asList
(
list
));
l
.
add
(
String
.
valueOf
(
av
.
getAucvehId
()));
redisCacheUtil
.
setCacheWithExpire
(
String
.
format
(
AUCTION_ORDER_KEY
,
auction
.
getAuctionId
()),
StringUtils
.
join
(
l
,
","
),
24
,
TimeUnit
.
HOURS
);
}
}
}
}
aus-core/src/main/java/com/glsx/usedcar/module/vehicle/entity/vo/VehicleAutoBidVO.java
View file @
c861af7
...
@@ -14,6 +14,10 @@ public class VehicleAutoBidVO {
...
@@ -14,6 +14,10 @@ public class VehicleAutoBidVO {
*/
*/
private
int
vehicleId
;
private
int
vehicleId
;
/**
/**
* 拍场id
*/
private
int
auctionId
;
/**
* 系统自动加价开关 1 开启 0 关闭 默认关闭
* 系统自动加价开关 1 开启 0 关闭 默认关闭
*/
*/
private
Integer
autoBidSwitch
;
private
Integer
autoBidSwitch
;
...
...
aus-core/src/main/java/com/glsx/usedcar/module/vehicle/service/VehicleService.java
View file @
c861af7
package
com
.
glsx
.
usedcar
.
module
.
vehicle
.
service
;
package
com
.
glsx
.
usedcar
.
module
.
vehicle
.
service
;
import
com.glsx.usedcar.module.analysis.domain.NameCount
;
import
com.glsx.usedcar.module.analysis.domain.NameCount
;
import
com.glsx.usedcar.module.auction.dao.AuctionDao
;
import
com.glsx.usedcar.module.auction.entity.Auction
;
import
com.glsx.usedcar.module.auction.entity.Auction.AuctionType
;
import
com.glsx.usedcar.module.auction.entity.dto.LightPollingBidConfigDTO
;
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.CarImage
;
import
com.glsx.usedcar.module.vehicle.domain.*
;
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.entity.vo.VehicleAutoBidVO
;
import
com.glsx.usedcar.module.vehicle.entity.vo.VehicleAutoBidVO
;
import
com.glsx.usedcar.module.venue.dao.AreaDao
;
import
com.glsx.usedcar.module.venue.dao.*
;
import
com.glsx.usedcar.module.venue.dao.VenueDao
;
import
com.glsx.usedcar.module.venue.entity.*
;
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.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
;
import
org.hibernate.ObjectNotFoundException
;
import
org.hibernate.ObjectNotFoundException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.data.jpa.domain.Specification
;
...
@@ -57,6 +56,9 @@ public class VehicleService {
...
@@ -57,6 +56,9 @@ public class VehicleService {
@Resource
@Resource
private
WarehousingDao
warehousingDao
;
private
WarehousingDao
warehousingDao
;
@Autowired
private
AuctionDao
auctionDao
;
/**
/**
* 通过ID查询一个库存车辆
* 通过ID查询一个库存车辆
*
*
...
@@ -336,6 +338,27 @@ public class VehicleService {
...
@@ -336,6 +338,27 @@ public class VehicleService {
)
{
)
{
return
BaseResp
.
fail
(
"车辆状态异常."
);
return
BaseResp
.
fail
(
"车辆状态异常."
);
}
}
// 自动出价触发秒数必须小于拍卖重置秒数
int
auctionId
=
vehicleAutoBidVO
.
getAuctionId
();
Optional
<
Auction
>
auctionOptional
=
auctionDao
.
findById
(
auctionId
);
if
(
auctionOptional
.
isEmpty
())
{
return
BaseResp
.
fail
(
"拍场不存在."
);
}
Auction
auction
=
auctionOptional
.
get
();
if
(
auction
.
getAuctionState
()
!=
Auction
.
AuctionState
.
AUCTIONING
&&
auction
.
getAuctionState
()
!=
Auction
.
AuctionState
.
WAIT_AUCTION
&&
auction
.
getAuctionState
()
!=
Auction
.
AuctionState
.
PREVIEW
)
{
return
BaseResp
.
fail
(
"拍场状态异常."
);
}
if
(
auction
.
getAuctionType
()
!=
AuctionType
.
LIGHT
||
auction
.
getAuctionMode
()
!=
2
)
{
return
BaseResp
.
fail
(
"暂时不支持配置"
);
}
String
extraJson
=
auction
.
getExtraJson
();
LightPollingBidConfigDTO
lightPollingBidConfigDTO
=
LightPollingBidConfigDTO
.
fromJson
(
extraJson
);
Integer
resetDelay
=
lightPollingBidConfigDTO
.
getResetDelay
();
if
(
resetDelay
<
vehicleAutoBidVO
.
getAutoBidTrigger
())
{
return
BaseResp
.
fail
(
"自动出价触发秒数必须小于拍卖重置秒数."
);
}
vehicle
.
setAutoBidSwitch
(
vehicleAutoBidVO
.
getAutoBidSwitch
());
vehicle
.
setAutoBidSwitch
(
vehicleAutoBidVO
.
getAutoBidSwitch
());
vehicle
.
setAutoBidRange
(
vehicleAutoBidVO
.
getAutoBidRange
());
vehicle
.
setAutoBidRange
(
vehicleAutoBidVO
.
getAutoBidRange
());
vehicle
.
setAutoBidTrigger
(
vehicleAutoBidVO
.
getAutoBidTrigger
());
vehicle
.
setAutoBidTrigger
(
vehicleAutoBidVO
.
getAutoBidTrigger
());
...
...
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