|
@@ -18,6 +18,7 @@ import cn.hobbystocks.auc.handle.context.LiveContext;
|
|
|
import cn.hobbystocks.auc.handle.context.tradition.TraditionLive;
|
|
import cn.hobbystocks.auc.handle.context.tradition.TraditionLive;
|
|
|
import cn.hobbystocks.auc.mapper.BidMapper;
|
|
import cn.hobbystocks.auc.mapper.BidMapper;
|
|
|
import cn.hobbystocks.auc.mapper.LotMapper;
|
|
import cn.hobbystocks.auc.mapper.LotMapper;
|
|
|
|
|
+import cn.hobbystocks.auc.realtime.LotRealtimePublisher;
|
|
|
import cn.hobbystocks.auc.service.IBidService;
|
|
import cn.hobbystocks.auc.service.IBidService;
|
|
|
import cn.hobbystocks.auc.vo.BidVO;
|
|
import cn.hobbystocks.auc.vo.BidVO;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -50,6 +51,8 @@ public class BidServiceImpl implements IBidService
|
|
|
public EventPublisher eventPublisher;
|
|
public EventPublisher eventPublisher;
|
|
|
@Autowired(required = false)
|
|
@Autowired(required = false)
|
|
|
private CacheMap cacheMap;
|
|
private CacheMap cacheMap;
|
|
|
|
|
+ @Autowired(required = false)
|
|
|
|
|
+ private LotRealtimePublisher lotRealtimePublisher;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public Bid selectBidById(Long id)
|
|
public Bid selectBidById(Long id)
|
|
@@ -73,6 +76,7 @@ public class BidServiceImpl implements IBidService
|
|
|
locker.tryLock(Constants.REDIS_LOCK_SYNC_LOT_TEMPLATE, () -> {
|
|
locker.tryLock(Constants.REDIS_LOCK_SYNC_LOT_TEMPLATE, () -> {
|
|
|
locker.tryLock(String.format(Constants.REDIS_LOCK_LOT_TEMPLATE, bid.getLotId()), () ->{
|
|
locker.tryLock(String.format(Constants.REDIS_LOCK_LOT_TEMPLATE, bid.getLotId()), () ->{
|
|
|
Live live = redisCache.getCacheMapValue(String.format(Constants.REDIS_MAP_AUC_LOT_TEMPLATE, bid.getAuctionId()), bid.getLotId().toString());
|
|
Live live = redisCache.getCacheMapValue(String.format(Constants.REDIS_MAP_AUC_LOT_TEMPLATE, bid.getAuctionId()), bid.getLotId().toString());
|
|
|
|
|
+ Long previousEndTime = live.getCurrentEndTime();
|
|
|
// 插入新的出价
|
|
// 插入新的出价
|
|
|
insertCurrBid(bid, live.getRound());
|
|
insertCurrBid(bid, live.getRound());
|
|
|
// 执行addPrice方法之前已进行了拍卖状态的判断
|
|
// 执行addPrice方法之前已进行了拍卖状态的判断
|
|
@@ -90,6 +94,7 @@ public class BidServiceImpl implements IBidService
|
|
|
redisCache.setList(String.format(Constants.REDIS_MAP_AUC_LOT_BID_TEMPLATE, live.getLot().getId()), bidList);
|
|
redisCache.setList(String.format(Constants.REDIS_MAP_AUC_LOT_BID_TEMPLATE, live.getLot().getId()), bidList);
|
|
|
live.getLot().setProperties(null);
|
|
live.getLot().setProperties(null);
|
|
|
redisCache.setCacheMapValue(String.format(Constants.REDIS_MAP_AUC_LOT_TEMPLATE, live.getLot().getAuctionId()), live.getLot().getId().toString(), live);
|
|
redisCache.setCacheMapValue(String.format(Constants.REDIS_MAP_AUC_LOT_TEMPLATE, live.getLot().getAuctionId()), live.getLot().getId().toString(), live);
|
|
|
|
|
+ publishRealtime(live, previousEndTime);
|
|
|
// 这里发送 状态变更消息 其中同步内存中的缓存和发送IM消息给APP
|
|
// 这里发送 状态变更消息 其中同步内存中的缓存和发送IM消息给APP
|
|
|
//TODO 异常问题
|
|
//TODO 异常问题
|
|
|
// eventPublisher.publishChangeEvent(new ChangeEvent(live, null, bidList));
|
|
// eventPublisher.publishChangeEvent(new ChangeEvent(live, null, bidList));
|
|
@@ -155,6 +160,12 @@ public class BidServiceImpl implements IBidService
|
|
|
return result.get();
|
|
return result.get();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void publishRealtime(Live live, Long previousEndTime) {
|
|
|
|
|
+ if (Objects.nonNull(lotRealtimePublisher)) {
|
|
|
|
|
+ lotRealtimePublisher.publish(live, previousEndTime);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private void insertCurrBid(BidVO bid, Long round) {
|
|
private void insertCurrBid(BidVO bid, Long round) {
|
|
|
bidMapper.clearCurrentBid(bid.getLotId());
|
|
bidMapper.clearCurrentBid(bid.getLotId());
|
|
|
bid.setDelFlag(Constants.DEL_FLAG_NO_DELETE);
|
|
bid.setDelFlag(Constants.DEL_FLAG_NO_DELETE);
|