|
@@ -1,24 +1,24 @@
|
|
|
package cn.hobbystocks.auc.service.impl;
|
|
package cn.hobbystocks.auc.service.impl;
|
|
|
|
|
|
|
|
import cn.hobbystocks.auc.cache.CacheMap;
|
|
import cn.hobbystocks.auc.cache.CacheMap;
|
|
|
-import cn.hobbystocks.auc.common.exception.AddPriceException;
|
|
|
|
|
-import cn.hobbystocks.auc.common.utils.CloneUtils;
|
|
|
|
|
-import cn.hobbystocks.auc.domain.Lot;
|
|
|
|
|
-import cn.hobbystocks.auc.event.ChangeEvent;
|
|
|
|
|
-import cn.hobbystocks.auc.event.EventPublisher;
|
|
|
|
|
-import cn.hobbystocks.auc.handle.context.LiveContext;
|
|
|
|
|
-import cn.hobbystocks.auc.handle.context.tradition.TraditionLive;
|
|
|
|
|
-import cn.hobbystocks.auc.service.IBidService;
|
|
|
|
|
import cn.hobbystocks.auc.common.constant.Constants;
|
|
import cn.hobbystocks.auc.common.constant.Constants;
|
|
|
import cn.hobbystocks.auc.common.core.redis.Locker;
|
|
import cn.hobbystocks.auc.common.core.redis.Locker;
|
|
|
import cn.hobbystocks.auc.common.core.redis.RedisCache;
|
|
import cn.hobbystocks.auc.common.core.redis.RedisCache;
|
|
|
import cn.hobbystocks.auc.common.core.text.Convert;
|
|
import cn.hobbystocks.auc.common.core.text.Convert;
|
|
|
|
|
+import cn.hobbystocks.auc.common.exception.AddPriceException;
|
|
|
|
|
+import cn.hobbystocks.auc.common.utils.CloneUtils;
|
|
|
import cn.hobbystocks.auc.common.utils.DateUtils;
|
|
import cn.hobbystocks.auc.common.utils.DateUtils;
|
|
|
import cn.hobbystocks.auc.domain.Bid;
|
|
import cn.hobbystocks.auc.domain.Bid;
|
|
|
|
|
+import cn.hobbystocks.auc.domain.Lot;
|
|
|
|
|
+import cn.hobbystocks.auc.event.ChangeEvent;
|
|
|
|
|
+import cn.hobbystocks.auc.event.EventPublisher;
|
|
|
import cn.hobbystocks.auc.handle.RuleHandlerHolder;
|
|
import cn.hobbystocks.auc.handle.RuleHandlerHolder;
|
|
|
import cn.hobbystocks.auc.handle.context.Live;
|
|
import cn.hobbystocks.auc.handle.context.Live;
|
|
|
|
|
+import cn.hobbystocks.auc.handle.context.LiveContext;
|
|
|
|
|
+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.service.IBidService;
|
|
|
import cn.hobbystocks.auc.vo.BidVO;
|
|
import cn.hobbystocks.auc.vo.BidVO;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -29,6 +29,7 @@ import org.springframework.transaction.annotation.Isolation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@Service
|
|
@Service
|
|
@@ -87,6 +88,7 @@ public class BidServiceImpl implements IBidService
|
|
|
lotMapper.updateLot(dbUpdate);
|
|
lotMapper.updateLot(dbUpdate);
|
|
|
List<Bid> bidList = bidMapper.selectBidListLimit(live.getLot().getId(), 20L);
|
|
List<Bid> bidList = bidMapper.selectBidListLimit(live.getLot().getId(), 20L);
|
|
|
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);
|
|
|
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);
|
|
|
// 这里发送 状态变更消息 其中同步内存中的缓存和发送IM消息给APP
|
|
// 这里发送 状态变更消息 其中同步内存中的缓存和发送IM消息给APP
|
|
|
eventPublisher.publishChangeEvent(new ChangeEvent(live, null, bidList));
|
|
eventPublisher.publishChangeEvent(new ChangeEvent(live, null, bidList));
|
|
@@ -137,6 +139,21 @@ public class BidServiceImpl implements IBidService
|
|
|
}, true);
|
|
}, true);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String getOrCreateUserCode(Long auctionId, String accountId) {
|
|
|
|
|
+ AtomicReference<String> result = new AtomicReference<>();
|
|
|
|
|
+ locker.tryLock(String.format("LOCK:AUC:USER_CODE:%s", auctionId), () -> {
|
|
|
|
|
+ String userCode = bidMapper.selectUserCodeByAuctionAndAccount(auctionId, accountId);
|
|
|
|
|
+ if (StringUtils.isNotEmpty(userCode)) {
|
|
|
|
|
+ result.set(userCode);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ Long maxUserCode = bidMapper.selectMaxUserCodeByAuction(auctionId);
|
|
|
|
|
+ result.set(String.valueOf(Objects.isNull(maxUserCode) ? 1L : maxUserCode + 1));
|
|
|
|
|
+ }, true, "获取竞买号失败");
|
|
|
|
|
+ return result.get();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
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);
|