LotServiceImpl.java 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040
  1. package cn.hobbystocks.auc.service.impl;
  2. import cn.hobbystocks.auc.cache.CacheMap;
  3. import cn.hobbystocks.auc.common.constant.Constants;
  4. import cn.hobbystocks.auc.common.core.redis.Locker;
  5. import cn.hobbystocks.auc.common.core.redis.RedisCache;
  6. import cn.hobbystocks.auc.common.core.text.Convert;
  7. import cn.hobbystocks.auc.common.enums.LotStatusEnum;
  8. import cn.hobbystocks.auc.common.enums.PubStatusEnum;
  9. import cn.hobbystocks.auc.common.enums.RuleTypeEnum;
  10. import cn.hobbystocks.auc.common.exception.ServiceException;
  11. import cn.hobbystocks.auc.common.user.UserInfo;
  12. import cn.hobbystocks.auc.common.user.UserUtils;
  13. import cn.hobbystocks.auc.common.utils.CloneUtils;
  14. import cn.hobbystocks.auc.common.utils.DateUtils;
  15. import cn.hobbystocks.auc.common.utils.SensitiveDataUtils;
  16. import cn.hobbystocks.auc.common.utils.StringUtils;
  17. import cn.hobbystocks.auc.convert.LotConvert;
  18. import cn.hobbystocks.auc.domain.*;
  19. import cn.hobbystocks.auc.dto.LotExportDTO;
  20. import cn.hobbystocks.auc.event.ChangeEvent;
  21. import cn.hobbystocks.auc.event.EventPublisher;
  22. import cn.hobbystocks.auc.event.JPushEvent;
  23. import cn.hobbystocks.auc.event.StartBiddingEvent;
  24. import cn.hobbystocks.auc.handle.RuleHandlerHolder;
  25. import cn.hobbystocks.auc.handle.context.Live;
  26. import cn.hobbystocks.auc.handle.context.LiveContext;
  27. import cn.hobbystocks.auc.handle.context.tradition.TraditionRule;
  28. import cn.hobbystocks.auc.mapper.*;
  29. import cn.hobbystocks.auc.request.LotQueryRequest;
  30. import cn.hobbystocks.auc.request.LotRequest;
  31. import cn.hobbystocks.auc.response.LotDetailResponse;
  32. import cn.hobbystocks.auc.response.LotFansResponse;
  33. import cn.hobbystocks.auc.service.ILotService;
  34. import cn.hobbystocks.auc.task.DynamicTaskService;
  35. import cn.hobbystocks.auc.vo.LiveVO;
  36. import cn.hobbystocks.auc.vo.LotVO;
  37. import cn.hobbystocks.auc.vo.SelfVO;
  38. import com.alibaba.fastjson.JSON;
  39. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  40. import com.baomidou.mybatisplus.core.metadata.IPage;
  41. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  42. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  43. import com.google.common.collect.Lists;
  44. import lombok.extern.slf4j.Slf4j;
  45. import org.springframework.beans.BeanUtils;
  46. import org.springframework.beans.factory.annotation.Autowired;
  47. import org.springframework.stereotype.Service;
  48. import org.springframework.transaction.annotation.Isolation;
  49. import org.springframework.transaction.annotation.Transactional;
  50. import org.springframework.util.CollectionUtils;
  51. import java.math.BigDecimal;
  52. import java.util.*;
  53. import java.util.concurrent.TimeUnit;
  54. import java.util.concurrent.atomic.AtomicLong;
  55. import java.util.regex.Matcher;
  56. import java.util.regex.Pattern;
  57. import java.util.stream.Collectors;
  58. @Service
  59. @Slf4j
  60. public class LotServiceImpl extends ServiceImpl<LotMapper,Lot> implements ILotService
  61. {
  62. @Autowired
  63. private LotMapper lotMapper;
  64. @Autowired
  65. private BidMapper bidMapper;
  66. @Autowired
  67. private Locker locker;
  68. @Autowired
  69. private RuleHandlerHolder ruleHandlerHolder;
  70. @Autowired
  71. private RedisCache redisCache;
  72. @Autowired
  73. private AuctionMapper auctionMapper;
  74. @Autowired
  75. public EventPublisher eventPublisher;
  76. @Autowired(required = false)
  77. private CacheMap cacheMap;
  78. @Autowired
  79. private DynamicTaskService dynamicTaskService;
  80. @Autowired
  81. private LotServiceImpl _thiz;
  82. @Autowired
  83. private LotGroupMapper lotGroupMapper;
  84. @Autowired
  85. private LotFansMapper lotFansMapper;
  86. @Autowired
  87. private SpuCategoryMapper spuCategoryMapper;
  88. @Autowired
  89. private DepositOrderMapper depositOrderMapper;
  90. @Override
  91. public Lot selectLotById(Long id) {
  92. return lotMapper.selectLotById(id);
  93. }
  94. @Override
  95. public LotGroup selectLotGroupById(Long id) {
  96. return lotGroupMapper.selectLotGroupById(id);
  97. }
  98. @Override
  99. public List<Lot> selectLotList(Lot lot) {
  100. IPage<Lot> lotIPage=new Page<>(lot.getPageNum(),lot.getPageSize());
  101. return lotMapper.selectLotList(lotIPage,lot);
  102. }
  103. @Override
  104. public List<Lot> selectBiddingLotByAucId(Long aucId) {
  105. return lotMapper.selectNotEndLotList(aucId);
  106. }
  107. @Override
  108. public List<Lot> selectLotByGroupIds(Long[] groupIds) {
  109. return null;
  110. }
  111. @Override
  112. public List<LotGroup> selectLotGroupList(LotGroup lotGroup) {
  113. return lotGroupMapper.selectLotGroupList(lotGroup);
  114. }
  115. @Override
  116. public void cancelLotGroup(Long id) {
  117. LotGroup dbLotGroup = lotGroupMapper.selectLotGroupById(id);
  118. dbLotGroup.setStatus(Constants.GROUP_STATUS_WAITING);
  119. dbLotGroup.setPubStatus(Constants.PUB_STATUS_NO_PUBLISHED);
  120. lotGroupMapper.updateLotGroup(dbLotGroup);
  121. }
  122. @Override
  123. public List<Lot> selectLotByGroupId(Long id) {
  124. return lotMapper.selectLotByGroupId(id);
  125. }
  126. @Override
  127. public List<LotGroup> canCreateLive(Long merchantId) {
  128. return lotGroupMapper.canCreateLive(merchantId);
  129. }
  130. @Override
  131. public List<LotGroup> findPubbedLotGroupByIds(Long[] lotGroupIds,Long merchantId) {
  132. return lotGroupMapper.findPubbedLotGroupByLotIds(lotGroupIds,merchantId);
  133. }
  134. @Override
  135. @Transactional(isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class)
  136. public Long party(LotGroup lotGroup) {
  137. AtomicLong result = new AtomicLong(0);
  138. locker.tryLock(String.format(Constants.REDIS_GROUP_LOCK_LOT_TEMPLATE, lotGroup.getId()), () -> {
  139. LotGroup dbLotGroup = lotGroupMapper.selectLotGroupById(lotGroup.getId());
  140. Lot currLot = lotMapper.selectLotById(dbLotGroup.getNextLotId());
  141. Lot nextLot = new Lot();
  142. BeanUtils.copyProperties(dbLotGroup, nextLot, "id");
  143. nextLot.setStatus(Constants.LOT_STATUS_WAITING);
  144. nextLot.setStartTime(null);
  145. nextLot.setCreateTime(new Date());
  146. nextLot.setUpdateTime(null);
  147. nextLot.setPubTime(new Date());
  148. nextLot.setPubStatus(Constants.PUB_STATUS_PUBLISHED);
  149. nextLot.setGroupId(lotGroup.getId());
  150. nextLot.setAuctionId(2L);
  151. String name = currLot.getName();
  152. int i = name.lastIndexOf("#");
  153. if (i > 0 && i != name.length() -1) {
  154. String numStr = name.substring(i + 1);
  155. String nextNum = "";
  156. try {
  157. long l = Long.parseLong(numStr);
  158. nextNum = "#" + (l + 1);
  159. }catch (Exception ignored) {}
  160. nextLot.setName(nextLot.getName() + nextNum);
  161. }
  162. lotMapper.updateLot(
  163. Lot.builder()
  164. .id(currLot.getId())
  165. .startTime(new Date())
  166. .build());
  167. currLot.setStartTime(new Date());
  168. long l = Objects.isNull(dbLotGroup.getFinishNum()) ? 0 : dbLotGroup.getFinishNum();
  169. if (l >= dbLotGroup.getNum()) {
  170. throw new RuntimeException("商品库存已经用完");
  171. }else if (l<dbLotGroup.getNum()-1){
  172. lotMapper.insertLot(nextLot);
  173. }
  174. lotGroupMapper.updateLotGroup(LotGroup.builder()
  175. .id(lotGroup.getId())
  176. .lotId(currLot.getId())
  177. .nextLotId(nextLot.getId())
  178. .finishNum(Objects.isNull(dbLotGroup.getFinishNum()) ? 0 : dbLotGroup.getFinishNum() + 1)
  179. .status(Constants.LOT_STATUS_STARTING)
  180. .build()
  181. );
  182. pubLot(currLot);
  183. result.set(currLot.getId());
  184. eventPublisher.publishStartBiddingEvent(new StartBiddingEvent(dbLotGroup.getId()));
  185. }, true, "开启失败,请重试!");
  186. return result.get();
  187. }
  188. @Override
  189. public List<LotGroup> findStartingGroupByLotIds(Long[] lotIds) {
  190. return lotGroupMapper.findStartingGroupByIds(lotIds);
  191. }
  192. @Override
  193. @Transactional(isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class)
  194. public void updateExpire(LotFans fans) {
  195. lotFansMapper.updateLotFans(
  196. LotFans.builder()
  197. .id(fans.getId())
  198. .type("pay_expire")
  199. .expire(DateUtils.addDays(DateUtils.toDate(fans.getCreateTime()), 1))
  200. .build());
  201. lotMapper.updateLot(Lot.builder().id(fans.getLotId()).status(Constants.LOT_STATUS_PASS).build());
  202. }
  203. @Override
  204. @Transactional(isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class)
  205. public void updateSoldAndPaid(LotFans fans, Long groupId) {
  206. lotFansMapper.deleteLotFansById(fans.getId());
  207. lotMapper.updatePay(fans.getLotId(), 1);
  208. lotGroupMapper.addSold(groupId);
  209. }
  210. @Override
  211. @Transactional(isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class)
  212. public void handleEndLotGroup(LotGroup lotGroup, String status) {
  213. LotGroup dbLotGroup = lotGroupMapper.selectLotGroupById(lotGroup.getId());
  214. lotGroupMapper.updateLotGroupSold(dbLotGroup.getId());
  215. }
  216. @Override
  217. @Transactional(isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class)
  218. public int insertLot(Lot lot) {
  219. lot.setCreateTime(DateUtils.getNowDate());
  220. int result = lotMapper.insertLot(lot);
  221. dynamicTask(lot);
  222. return result;
  223. }
  224. @Override
  225. @Transactional(isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class)
  226. public int insertLotGroup(LotGroup lotGroup) {
  227. final int i = lotGroupMapper.insertLotGroup(lotGroup);
  228. Lot lot = new Lot();
  229. BeanUtils.copyProperties(lotGroup, lot, "id");
  230. lot.setStatus(Constants.LOT_STATUS_WAITING);
  231. lot.setStartTime(null);
  232. lot.setCreateTime(new Date());
  233. lot.setUpdateTime(null);
  234. lot.setPubTime(new Date());
  235. lot.setPubStatus(Constants.PUB_STATUS_PUBLISHED);
  236. lot.setGroupId(lotGroup.getId());
  237. lot.setNum(1L);
  238. lot.setName(lot.getName() + "#1");
  239. lotMapper.insertLot(lot);
  240. lotGroupMapper.updateLotGroup(LotGroup.builder().id(lotGroup.getId()).nextLotId(lot.getId()).build());
  241. return i;
  242. }
  243. @Override
  244. public int updateLot(Lot lot) {
  245. lot.setUpdateTime(DateUtils.getNowDate());
  246. return lotMapper.updateLot(lot);
  247. }
  248. @Override
  249. @Transactional(isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class)
  250. public int updateLotGroup(LotGroup lotGroup) {
  251. LotGroup dbLotGroup = lotGroupMapper.selectLotGroupById(lotGroup.getId());
  252. if (Objects.nonNull(lotGroup.getNum()) && dbLotGroup.getNum() > lotGroup.getNum()) {
  253. int count = lotMapper.selectLotByGroupId(lotGroup.getId()).size() - 1;
  254. if (count > lotGroup.getNum()) {
  255. throw new RuntimeException("数量不合法");
  256. }
  257. }
  258. lotGroup.setUpdateTime(DateUtils.getNowDate());
  259. int result = lotGroupMapper.updateLotGroup(lotGroup);
  260. dbLotGroup = lotGroupMapper.selectLotGroupById(lotGroup.getId());
  261. Lot lot = lotMapper.selectLotById(dbLotGroup.getNextLotId());
  262. if (Constants.LOT_STATUS_WAITING.equals(lot.getStatus())) {
  263. String name = lot.getName();
  264. String nextNum = "";
  265. int i = name.lastIndexOf("#");
  266. if (i > 0 && i != name.length() -1) {
  267. String numStr = name.substring(i + 1);
  268. try {
  269. long l = Long.parseLong(numStr);
  270. nextNum = "#" + l;
  271. }catch (Exception ignored) {}
  272. }
  273. BeanUtils.copyProperties(dbLotGroup, lot, "id","createTime", "name");
  274. lot.setStatus(Constants.LOT_STATUS_WAITING);
  275. lot.setStartTime(null);
  276. lot.setPubTime(new Date());
  277. lot.setPubStatus(Constants.PUB_STATUS_PUBLISHED);
  278. lot.setGroupId(lotGroup.getId());
  279. lot.setName(dbLotGroup.getName() + nextNum);
  280. updateLot(lot);
  281. }
  282. return result;
  283. }
  284. @Override
  285. @Transactional(isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class)
  286. public int updateLotGroup0(LotGroup lotGroup) {
  287. return lotGroupMapper.updateLotGroup(lotGroup);
  288. }
  289. @Override
  290. public int updateLotView(Lot lot) {
  291. lot.setUpdateTime(DateUtils.getNowDate());
  292. int result = lotMapper.updateLotView(lot);
  293. dynamicTask(lot);
  294. return result;
  295. }
  296. @Override
  297. @Transactional(isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class)
  298. public int updateLotEx(Lot lot) {
  299. lot.setUpdateTime(DateUtils.getNowDate());
  300. int result = lotMapper.updateLotEx(lot);
  301. dynamicTask(lot);
  302. return result;
  303. }
  304. @Override
  305. public List<Lot> selectBidding() {
  306. return lotMapper.selectBidding();
  307. }
  308. @Override
  309. public List<Lot> selectCancel() {
  310. return lotMapper.selectCancel();
  311. }
  312. @Override
  313. public int deleteLotByIds(String ids) {
  314. return lotMapper.deleteLotByIds(Convert.toLongArray(ids));
  315. }
  316. @Override
  317. public int deleteLotById(Long id) {
  318. return lotMapper.deleteLotById(id);
  319. }
  320. @Override
  321. @Transactional(isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class)
  322. public void pubLot(Lot lot) {
  323. locker.tryLock(String.format(Constants.REDIS_LOCK_LOT_TEMPLATE, lot.getId()), () ->{
  324. lot.setPubTime(new Date());
  325. lot.setPubStatus(Constants.PUB_STATUS_PUBLISHED);
  326. lot.setUpdateTime(new Date());
  327. lotMapper.updateLot(lot);
  328. //构建竞价拍卖上下文
  329. LiveContext liveContext = ruleHandlerHolder.pubLive(lot);
  330. if (liveContext.isLotUpdate()) {
  331. lotMapper.updateLot(lot);
  332. }
  333. redisCache.setCacheMapValue(String.format(Constants.REDIS_MAP_AUC_LOT_TEMPLATE, lot.getAuctionId()), lot.getId().toString(), liveContext.getLive());
  334. }, true);
  335. }
  336. @Override
  337. @Transactional(isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class)
  338. public void pubLots(Auction auction) {
  339. List<Lot> lots = lotMapper.selectLotByAucId(auction.getId());
  340. for (Lot lot : lots) {
  341. lot.setUpdateBy(auction.getUpdateBy());
  342. pubLot(lot);
  343. }
  344. }
  345. @Override
  346. @Transactional(isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class)
  347. public void insertLotAndPub(Lot lot) {
  348. insertLot(lot);
  349. pubLot(lot);
  350. }
  351. @Override
  352. @Transactional(isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class)
  353. public void updateLotAndPub(Lot lot) {
  354. updateLot(lot);
  355. pubLot(lot);
  356. }
  357. @Override
  358. public void removeLot(Lot lot) {
  359. Lot condition = new Lot();
  360. condition.setId(lot.getId());
  361. condition.setDelFlag(Constants.DEL_FLAG_DELETED);
  362. lotMapper.updateLot(condition);
  363. }
  364. @Override
  365. public void cancelLot(Lot lot) {
  366. lot.setUpdateTime(new Date());
  367. lot.setStatus(Constants.LOT_STATUS_CANCELLED);
  368. lot.setPubStatus(Constants.PUB_STATUS_NO_PUBLISHED);
  369. lotMapper.updateLot(lot);
  370. ruleHandlerHolder.cancelLot(lot);
  371. }
  372. @Override
  373. @Transactional(isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class)
  374. public void live(Live live) {
  375. live = redisCache.getCacheMapValue(String.format(Constants.REDIS_MAP_AUC_LOT_TEMPLATE, live.getLot().getAuctionId()), live.getLot().getId().toString());
  376. // 1秒的轮询 会存在失效数据 判断是否是失效数据
  377. if (Objects.isNull(live)) {
  378. //是失效数据
  379. return;
  380. }
  381. cacheMap.putLive(live);
  382. List<Bid> bidList = redisCache.getCacheList(String.format(Constants.REDIS_MAP_AUC_LOT_BID_TEMPLATE, live.getLot().getId()));
  383. // 创建当前 context
  384. LiveContext liveContext = LiveContext.builder()
  385. .live(live)
  386. .dbLot(Lot.builder()
  387. .id(live.getLot().getId())
  388. .auctionId(live.getLot().getAuctionId())
  389. .build())
  390. .bidList(bidList)
  391. .dbBid(getLastBid(bidList))
  392. .build();
  393. // 分析并设置当前状态
  394. ruleHandlerHolder.live(liveContext);
  395. // 更新当前状态 到数据库和缓存
  396. updateToRedisAndDb(liveContext);
  397. // 发送极光推送
  398. jPush(liveContext);
  399. }
  400. private void jPush(LiveContext liveContext) {
  401. Live live = liveContext.getLive();
  402. if (live.getCurrentEndTime() < (System.currentTimeMillis() + 1000 * 60 * 5)) {
  403. Long expire = redisCache.redisTemplate.getExpire(String.format(Constants.REDIS_LOCK_PUSH_LOT_TEMPLATE, live.getLot().getId()));
  404. if (Objects.isNull(expire) || expire < 0L) {
  405. eventPublisher.publishJPush(JPushEvent.builder().live(live).build());
  406. redisCache.setCacheObject(String.format(Constants.REDIS_LOCK_PUSH_LOT_TEMPLATE, live.getLot().getId()), "jPush", 10, TimeUnit.MINUTES);
  407. }
  408. }
  409. }
  410. private Bid getLastBid(List<Bid> bidList) {
  411. if (!CollectionUtils.isEmpty(bidList)) {
  412. return bidList.get(0);
  413. }
  414. return null;
  415. }
  416. private void updateToRedisAndDb(LiveContext liveContext) {
  417. Live live = liveContext.getLive();
  418. List<Bid> dataList = liveContext.getBidList();
  419. ChangeEvent changeEvent = new ChangeEvent(live);
  420. if (liveContext.isLotUpdate()) {
  421. liveContext.getDbLot().setUpdateTime(new Date());
  422. lotMapper.updateLot(liveContext.getDbLot());
  423. }
  424. if (liveContext.isBidUpdate()) {
  425. bidMapper.updateBid(liveContext.getDbBid());
  426. redisCache.setList(String.format(Constants.REDIS_MAP_AUC_LOT_BID_TEMPLATE, live.getLot().getId()), dataList);
  427. changeEvent.setBid(liveContext.getDbBid());
  428. }
  429. Lot lot = live.getLot();
  430. lot.setProperties(null);
  431. if (liveContext.isLiveUpdate()) {
  432. if (Constants.LOT_STATUS_SOLD.equals(live.getLot().getStatus()) ||
  433. Constants.LOT_STATUS_PASS.equals(live.getLot().getStatus())) {
  434. redisCache.delCacheMapValue(String.format(Constants.REDIS_MAP_AUC_LOT_TEMPLATE, live.getLot().getAuctionId()), live.getLot().getId().toString());
  435. redisCache.deleteObject(String.format(Constants.REDIS_MAP_AUC_LOT_BID_TEMPLATE, live.getLot().getId()));
  436. if (Constants.LOT_STATUS_SOLD.equals(live.getLot().getStatus())) {
  437. if(live.getBidId()==null){
  438. long bidid = bidMapper.getCurrentBid(live.getLot().getId());
  439. live.setBidId(bidid);
  440. }
  441. eventPublisher.publishSoldEvent(live, dataList);
  442. }
  443. eventPublisher.publishEndEvent(live);
  444. }else {
  445. redisCache.setCacheMapValue(String.format(Constants.REDIS_MAP_AUC_LOT_TEMPLATE, live.getLot().getAuctionId()), live.getLot().getId().toString(), live);
  446. }
  447. eventPublisher.publishChangeEvent(changeEvent);
  448. }
  449. }
  450. @Override
  451. public List<Lot> live(Long auctionId) {
  452. LambdaQueryWrapper<Lot> queryWrapper=new LambdaQueryWrapper<>();
  453. queryWrapper.eq(Lot::getAuctionId,auctionId).eq(Lot::getDelFlag,Constants.DEL_FLAG_NO_DELETE);
  454. return lotMapper.selectList(queryWrapper);
  455. }
  456. @Override
  457. public List<LiveVO> selfLive(SelfVO selfVO) {
  458. UserInfo userInfo = UserUtils.getSimpleUserInfo();
  459. if (userInfo == null) {
  460. throw new ServiceException("璇峰厛鐧诲綍");
  461. }
  462. List<DepositOrder> depositOrders = selectPaidDepositOrders(userInfo.getId());
  463. List<Bid> userBidList = bidMapper.selectBidList(Bid.builder()
  464. .accountId(userInfo.getId().toString())
  465. .build());
  466. List<Lot> candidateLots = selectSelfCandidateLots(depositOrders, userBidList.stream()
  467. .map(Bid::getLotId)
  468. .filter(Objects::nonNull)
  469. .collect(Collectors.toSet()));
  470. Map<String, Live> cacheLive = new HashMap<>();
  471. candidateLots.stream()
  472. .map(Lot::getAuctionId)
  473. .filter(Objects::nonNull)
  474. .distinct()
  475. .forEach(auctionId -> {
  476. Map<String, Live> auctionLive = CloneUtils.clone(cacheMap.viewAuction(auctionId));
  477. if (!CollectionUtils.isEmpty(auctionLive)) {
  478. cacheLive.putAll(auctionLive);
  479. }
  480. });
  481. return cacheLive.values().stream()
  482. .filter(live -> live.getAccountList().contains(UserUtils.getSimpleUserInfo().getId().toString()) &&
  483. Constants.LOT_STATUS_BIDDING.equals(live.getLot().getStatus()))
  484. .map(live -> {
  485. List<Bid> bidList = bidMapper.selectBidByLotId(live.getLot().getId());
  486. LiveVO liveVO = new LiveVO(live);
  487. if (!CollectionUtils.isEmpty(bidList)) {
  488. liveVO.setLastPriceTime(bidList.get(0).getCreateTime().getTime());
  489. }
  490. liveVO.setCurrUserBids(
  491. Objects.requireNonNull(bidList).stream()
  492. .filter(bid -> bid.getAccountId().equals(UserUtils.getSimpleUserInfo().getId().toString()))
  493. .collect(Collectors.toList())
  494. );
  495. return SensitiveDataUtils.handleViewDataSafe(liveVO);
  496. }).sorted(this::sort)
  497. .collect(Collectors.toList());
  498. }
  499. private int sort(LiveVO live1, LiveVO live2) {
  500. return (int)(live2.getLastPriceTime() - live1.getLastPriceTime());
  501. }
  502. @Override
  503. public List<LotVO> selfFinish(SelfVO selfVO) {
  504. return finishOrWin(null);
  505. }
  506. @Override
  507. public List<LotVO> selfWin(SelfVO selfVO) {
  508. return finishOrWin(1);
  509. }
  510. @Override
  511. public List<LotVO> selfList(SelfVO selfVO) {
  512. UserInfo userInfo = UserUtils.getSimpleUserInfo();
  513. if (userInfo == null) {
  514. throw new ServiceException("请先登录");
  515. }
  516. String userId = userInfo.getId().toString();
  517. List<DepositOrder> depositOrders = selectPaidDepositOrders(userInfo.getId());
  518. List<Bid> userBidList = bidMapper.selectBidList(Bid.builder()
  519. .accountId(userId)
  520. .build());
  521. Map<Long, List<Bid>> userBidMap = userBidList.stream()
  522. .filter(bid -> Objects.nonNull(bid.getLotId()))
  523. .collect(Collectors.groupingBy(Bid::getLotId));
  524. List<Lot> lotList = selectSelfCandidateLots(depositOrders, userBidMap.keySet());
  525. String type = StringUtils.isEmpty(selfVO.getType()) ? "all" : selfVO.getType();
  526. List<LotVO> result = new ArrayList<>();
  527. for (Lot lot : lotList) {
  528. List<Bid> userBids = userBidMap.getOrDefault(lot.getId(), Collections.emptyList());
  529. boolean hasUserBid = !CollectionUtils.isEmpty(userBids);
  530. boolean hasWinBid = hasUserBid && userBids.stream().anyMatch(bid -> Objects.equals(bid.getStatus(), 1));
  531. boolean hasDeposit = hasDepositQualification(lot, depositOrders);
  532. String selfStatus = resolveSelfStatus(lot, hasDeposit, hasUserBid, hasWinBid);
  533. if (matchSelfScene(type, selfStatus)) {
  534. result.add(buildSelfLotVo(lot, userBids, selfStatus));
  535. }
  536. }
  537. sortSelfLots(type, result);
  538. return result;
  539. }
  540. private List<DepositOrder> selectPaidDepositOrders(Integer userId) {
  541. return depositOrderMapper.selectList(new LambdaQueryWrapper<DepositOrder>()
  542. .eq(DepositOrder::getUserId, userId)
  543. .eq(DepositOrder::getStatus, 1));
  544. }
  545. private List<Lot> selectSelfCandidateLots(List<DepositOrder> depositOrders, Collection<Long> bidLotIds) {
  546. Map<Long, Lot> lotMap = new LinkedHashMap<>();
  547. if (!CollectionUtils.isEmpty(depositOrders)) {
  548. depositOrders.stream()
  549. .map(DepositOrder::getAuctionId)
  550. .filter(Objects::nonNull)
  551. .distinct()
  552. .forEach(auctionId -> addLots(lotMap, lotMapper.selectLotByAucId(auctionId)));
  553. }
  554. Set<Long> lotIds = new LinkedHashSet<>();
  555. if (!CollectionUtils.isEmpty(bidLotIds)) {
  556. lotIds.addAll(bidLotIds);
  557. }
  558. if (!CollectionUtils.isEmpty(depositOrders)) {
  559. depositOrders.stream()
  560. .map(DepositOrder::getLotId)
  561. .filter(Objects::nonNull)
  562. .forEach(lotIds::add);
  563. }
  564. if (!CollectionUtils.isEmpty(lotIds)) {
  565. addLots(lotMap, lotMapper.selectLotListByLotIds(new ArrayList<>(lotIds)));
  566. }
  567. return new ArrayList<>(lotMap.values());
  568. }
  569. private void addLots(Map<Long, Lot> lotMap, List<Lot> lots) {
  570. if (CollectionUtils.isEmpty(lots)) {
  571. return;
  572. }
  573. lots.stream()
  574. .filter(lot -> Objects.nonNull(lot.getId()))
  575. .forEach(lot -> lotMap.put(lot.getId(), lot));
  576. }
  577. private boolean hasDepositQualification(Lot lot, List<DepositOrder> depositOrders) {
  578. if (CollectionUtils.isEmpty(depositOrders)) {
  579. return false;
  580. }
  581. if (Objects.nonNull(lot.getDeposit())) {
  582. return depositOrders.stream().anyMatch(order -> Objects.equals("拍品", order.getDepositType())
  583. && Objects.equals(order.getLotId(), lot.getId()));
  584. }
  585. return depositOrders.stream().anyMatch(order -> Objects.equals("拍卖会", order.getDepositType())
  586. && Objects.equals(order.getAuctionId(), lot.getAuctionId()));
  587. }
  588. private String resolveSelfStatus(Lot lot, boolean hasDeposit, boolean hasUserBid, boolean hasWinBid) {
  589. if (isWaitingLot(lot, hasDeposit)) {
  590. return "waiting";
  591. }
  592. if (isLiveLot(lot, hasDeposit, hasUserBid)) {
  593. return "live";
  594. }
  595. if (isWinLot(lot, hasWinBid)) {
  596. return "win";
  597. }
  598. if (isLoseLot(lot, hasUserBid, hasWinBid)) {
  599. return "lose";
  600. }
  601. return null;
  602. }
  603. private boolean matchSelfScene(String type, String selfStatus) {
  604. if (StringUtils.isEmpty(selfStatus)) {
  605. return false;
  606. }
  607. if ("all".equals(type)) {
  608. return true;
  609. }
  610. if ("lose".equals(type) || "pass".equals(type) || "finish".equals(type)) {
  611. return "lose".equals(selfStatus);
  612. }
  613. if ("win".equals(type)) {
  614. return "win".equals(selfStatus);
  615. }
  616. return type.equals(selfStatus);
  617. }
  618. private boolean isWaitingLot(Lot lot, boolean hasDeposit) {
  619. return Constants.LOT_STATUS_WAITING.equals(lot.getStatus()) && hasDeposit;
  620. }
  621. private boolean isLiveLot(Lot lot, boolean hasDeposit, boolean hasUserBid) {
  622. return (Constants.LOT_STATUS_STARTING.equals(lot.getStatus()) || Constants.LOT_STATUS_BIDDING.equals(lot.getStatus()))
  623. && (hasDeposit || hasUserBid);
  624. }
  625. private boolean isWinLot(Lot lot, boolean hasWinBid) {
  626. return Constants.LOT_STATUS_SOLD.equals(lot.getStatus()) && hasWinBid;
  627. }
  628. private boolean isLoseLot(Lot lot, boolean hasUserBid, boolean hasWinBid) {
  629. if (!hasUserBid) {
  630. return false;
  631. }
  632. if (Constants.LOT_STATUS_PASS.equals(lot.getStatus())) {
  633. return true;
  634. }
  635. return Constants.LOT_STATUS_SOLD.equals(lot.getStatus()) && !hasWinBid;
  636. }
  637. private LotVO buildSelfLotVo(Lot lot, List<Bid> userBids, String selfStatus) {
  638. LotVO lotVO = new LotVO();
  639. BeanUtils.copyProperties(lot, lotVO);
  640. lotVO.setBids(userBids);
  641. TraditionRule rule = StringUtils.isEmpty(lot.getRuleContent())
  642. ? null
  643. : JSON.parseObject(lot.getRuleContent(), TraditionRule.class);
  644. lotVO.setStartPrice(Objects.isNull(rule) ? null : rule.getStartPrice());
  645. lotVO.setCurrentPrice(Objects.nonNull(lot.getLastPrice()) ? lot.getLastPrice() : null);
  646. lotVO.setSelfStatus(selfStatus);
  647. return SensitiveDataUtils.handleViewDataSafe(lotVO);
  648. }
  649. private void sortSelfLots(String type, List<LotVO> lots) {
  650. if ("waiting".equals(type)) {
  651. lots.sort(Comparator.comparing(Lot::getStartTime, Comparator.nullsLast(Date::compareTo)));
  652. return;
  653. }
  654. if ("live".equals(type)) {
  655. lots.sort(Comparator.comparing(Lot::getLastPriceTime, Comparator.nullsLast(Date::compareTo)).reversed());
  656. return;
  657. }
  658. if ("lose".equals(type) || "pass".equals(type) || "finish".equals(type) || "win".equals(type)) {
  659. lots.sort(Comparator.comparing(Lot::getRealEndTime, Comparator.nullsLast(Date::compareTo)).reversed());
  660. return;
  661. }
  662. List<LotVO> waiting = lots.stream().filter(lot -> "waiting".equals(lot.getSelfStatus()))
  663. .sorted(Comparator.comparing(Lot::getStartTime, Comparator.nullsLast(Date::compareTo)))
  664. .collect(Collectors.toList());
  665. List<LotVO> live = lots.stream()
  666. .filter(lot -> "live".equals(lot.getSelfStatus()))
  667. .sorted(Comparator.comparing(Lot::getLastPriceTime, Comparator.nullsLast(Date::compareTo)).reversed())
  668. .collect(Collectors.toList());
  669. List<LotVO> lose = lots.stream()
  670. .filter(lot -> "lose".equals(lot.getSelfStatus()) || "win".equals(lot.getSelfStatus()))
  671. .sorted(Comparator.comparing(Lot::getRealEndTime, Comparator.nullsLast(Date::compareTo)).reversed())
  672. .collect(Collectors.toList());
  673. lots.clear();
  674. lots.addAll(waiting);
  675. lots.addAll(live);
  676. lots.addAll(lose);
  677. }
  678. private List<LotVO> finishOrWin(Integer win) {
  679. String account = UserUtils.getSimpleUserInfo().getId().toString();
  680. List<LotVO> resultList = new ArrayList<>();
  681. List<Lot> lotList = lotMapper.selectLotFinishOrWin(win, account);
  682. lotList.forEach(lot -> {
  683. if (Constants.LOT_STATUS_PASS.equals(lot.getStatus()) || Constants.LOT_STATUS_SOLD.equals(lot.getStatus())) {
  684. Bid condition = new Bid();
  685. condition.setLotId(lot.getId());
  686. condition.setAccountId(account);
  687. condition.setStatus(win);
  688. List<Bid> bids = bidMapper.selectBidList(condition);
  689. if (!CollectionUtils.isEmpty(bids)) {
  690. LotVO lotVO = new LotVO();
  691. BeanUtils.copyProperties(lot, lotVO);
  692. lotVO.setBids(bids);
  693. resultList.add(SensitiveDataUtils.handleViewDataSafe(lotVO));
  694. }
  695. }
  696. });
  697. return resultList;
  698. }
  699. @Override
  700. @Transactional(isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class)
  701. public void handleDelay(Long id) {
  702. Lot dbLot = lotMapper.selectLotById(id);
  703. Lot update = new Lot();
  704. BeanUtils.copyProperties(dbLot, update);
  705. update.setCreateBy("SYSTEM");
  706. update.setCreateTime(new Date());
  707. update.setPubStatus(Constants.PUB_STATUS_NO_PUBLISHED);
  708. update.setStatus(Constants.LOT_STATUS_WAITING);
  709. update.setDelFlag(Constants.DEL_FLAG_NO_DELETE);
  710. update.setStartTime(DateUtils.addDays(dbLot.getStartTime(), 1));
  711. update.setEndTime(DateUtils.addDays(dbLot.getEndTime(), 1));
  712. String name = update.getName();
  713. if (!StringUtils.isEmpty(name)) {
  714. Pattern pattern = Pattern.compile("第(\\d+)期");
  715. Matcher matcher = pattern.matcher(name);
  716. if (matcher.find()) {
  717. String group = matcher.group(0);
  718. String noStr = matcher.group(1);
  719. int no = (Integer.parseInt(noStr)) + 1;
  720. name = name.replace(group, "第" + no + "期");
  721. update.setName(name);
  722. }
  723. }
  724. lotMapper.insertLotClone(update);
  725. dbLot.setDelayPublish(null);
  726. lotMapper.updateLotView(dbLot);
  727. if (!Objects.equals(dbLot.getPubStatus(), Constants.PUB_STATUS_PUBLISHED)) {
  728. pubLot(dbLot);
  729. }
  730. dynamicTask(update);
  731. }
  732. @Override
  733. public void dynamicTasks() {
  734. lotMapper.dynamicLot().forEach(this::dynamicTask);
  735. }
  736. @Override
  737. public void dynamicTask(Lot lot) {
  738. //延时发布时间
  739. String delayPublish = lot.getDelayPublish();
  740. if (!StringUtils.isEmpty(delayPublish)) {
  741. dynamicTaskService.updateTask(lot.getId().toString(), DateUtils.getNextExecutionTime(delayPublish), () -> {
  742. _thiz.handleDelay(lot.getId());
  743. });
  744. }else {
  745. dynamicTaskService.removeTask(lot.getId().toString());
  746. }
  747. }
  748. @Override
  749. public List<Lot> selectLotListByAucId(Long aucId) {
  750. return getBaseMapper().selectLotByAucId(aucId);
  751. }
  752. @Override
  753. public void calculatorAndUpdateLotHot() {
  754. //查询正在竞价中的拍品
  755. List<Lot> lots = lotMapper.selectBidding();
  756. lots.forEach(lot -> {
  757. //计算出价权重
  758. double bidWeight = lot.getBidCount() * 0.5;
  759. //计算收藏权重
  760. LambdaQueryWrapper<LotFans> lotFansLambdaQueryWrapper = new LambdaQueryWrapper<>();
  761. Long lotFansCount = lotFansMapper.selectCount(lotFansLambdaQueryWrapper.eq(LotFans::getLotId, lot.getId()));
  762. double lotFansWeight = lotFansCount * 0.2;
  763. //计算时间权重,竞拍结束时间-当前时间=剩余时间
  764. Date endTime = lot.getEndTime();
  765. int timeWeight;
  766. Date date = new Date();
  767. Date date1 = DateUtils.addHours(date, 2);
  768. if (date1.after(endTime)){
  769. }
  770. //计算涨价幅度权重
  771. Long currentBid = bidMapper.getCurrentBid(lot.getId());
  772. });
  773. }
  774. @Override
  775. public List<Lot> selectBiddingLotList() {
  776. return getBaseMapper().selectBiddingLotList();
  777. }
  778. @Override
  779. public List<LotFansResponse> queryLotByCategory(LotQueryRequest request) {
  780. // 1. 构建最终要查询的分类ID
  781. List<Long> categoryIds = Lists.newArrayList();
  782. if (Objects.nonNull(request.getChildCategoryId())) {
  783. // 传了二级分类 → 直接用
  784. categoryIds.add(request.getChildCategoryId());
  785. } else if (Objects.nonNull(request.getMainCategoryId())) {
  786. // 只传一级 → 查询该一级下所有二级ID
  787. categoryIds = spuCategoryMapper.listChildByParentId(request.getMainCategoryId());
  788. }
  789. // 2. 没有分类 → 返回空
  790. if (CollectionUtils.isEmpty(categoryIds)) {
  791. return Lists.newArrayList();
  792. }
  793. // 3. 查询拍品ID
  794. List<Long> lotIds = spuCategoryMapper.listLotIdsByCategoryIds(categoryIds);
  795. if (CollectionUtils.isEmpty(lotIds)) {
  796. return Lists.newArrayList();
  797. }
  798. IPage<Lot> lotIPage =new Page<>(request.getPageNum(),request.getPageSize());
  799. Lot lot = new Lot();
  800. lot.setIds(lotIds);
  801. lot.setName(request.getName());
  802. lot.setPubStatus(request.getPubStatus());
  803. lot.setStatus(request.getStatus());
  804. lot.setStartTime(request.getStartTime());
  805. lot.setEndTime(request.getEndTime());
  806. lot.setRealEndTime(request.getRealEndTime());
  807. List<Lot> diamondPositions = baseMapper.selectLotList(lotIPage, lot);
  808. List<LotFansResponse> lotFansResponses = diamondPositions.stream().map(LotConvert.INSTANCE::toLotFansResponse).collect(Collectors.toList());
  809. return lotFansResponses;
  810. }
  811. @Override
  812. public LotDetailResponse queryLotDetail(Long lotId) {
  813. Lot lot = lotMapper.selectLotById(lotId);
  814. if (Objects.isNull(lot)) {
  815. throw new ServiceException("未找到拍品数据");
  816. }
  817. Auction auction = auctionMapper.selectAuctionById(lot.getAuctionId());
  818. if (Objects.isNull(auction)) {
  819. throw new ServiceException("未找到拍卖会相关数据");
  820. }
  821. TraditionRule rule = StringUtils.isEmpty(lot.getRuleContent())
  822. ? null
  823. : JSON.parseObject(lot.getRuleContent(), TraditionRule.class);
  824. BigDecimal startPrice = Objects.isNull(rule) ? null : rule.getStartPrice();
  825. BigDecimal markupAmount = Objects.isNull(rule) ? null : rule.getDefaultOnceAddPrice();
  826. Long depositAmount = lot.getDeposit();
  827. String depositType = "LOT";
  828. if (Objects.isNull(depositAmount)) {
  829. depositAmount = auction.getDeposit();
  830. depositType = "AUCTION";
  831. }
  832. LotDetailResponse response = new LotDetailResponse();
  833. response.setLotId(lot.getId());
  834. response.setAuctionId(lot.getAuctionId());
  835. response.setName(lot.getName());
  836. response.setAuctionName(auction.getName());
  837. response.setAuctionDesc(auction.getDescription());
  838. response.setRuleContent(lot.getRuleContent());
  839. response.setAuctionImgs(auction.getImgs());
  840. response.setImgs(lot.getImgs());
  841. response.setCarouselImgs(lot.getCarouselImgs());
  842. response.setStatus(lot.getStatus());
  843. Date startTime = toBeijingTime(lot.getStartTime());
  844. Date endTime = toBeijingTime(lot.getEndTime());
  845. Date realEndTime = toBeijingTime(lot.getRealEndTime());
  846. response.setStartTime(startTime);
  847. response.setEndTime(endTime);
  848. response.setRealEndTime(realEndTime);
  849. response.setStartPrice(startPrice);
  850. response.setCurrentPrice(Objects.nonNull(lot.getLastPrice()) ? lot.getLastPrice() : startPrice);
  851. response.setBidCount(lot.getBidCount());
  852. response.setDepositAmount(depositAmount);
  853. response.setDepositType(depositType);
  854. response.setServiceTariff(lot.getServiceTariff());
  855. response.setRuleType(lot.getRuleType());
  856. response.setMarkupAmount(markupAmount);
  857. response.setDetail(lot.getDetail());
  858. response.setProperties(lot.getProperties());
  859. response.setIsFans(Boolean.FALSE);
  860. response.setHasDeposit(Boolean.FALSE);
  861. response.setPayTimeLimit(lot.getPayTimeLimit());
  862. if (Objects.equals("Waiting", lot.getStatus()) && Objects.nonNull(startTime)) {
  863. response.setTimestamp(startTime.getTime() - System.currentTimeMillis());
  864. } else if (Objects.equals("Bidding", lot.getStatus()) && Objects.nonNull(endTime)) {
  865. response.setTimestamp(endTime.getTime() - System.currentTimeMillis());
  866. }
  867. //TODO 成交用户暂时无
  868. fillUserFlags(lot, response, depositType);
  869. return response;
  870. }
  871. private Date toBeijingTime(Date date) {
  872. return Objects.isNull(date) ? null : DateUtils.addHours(date, 8);
  873. }
  874. private void fillUserFlags(Lot lot, LotDetailResponse response, String depositType) {
  875. UserInfo userInfo = UserUtils.getSimpleUserInfo();
  876. if (Objects.isNull(userInfo)) {
  877. return;
  878. }
  879. Long favoriteCount = lotFansMapper.selectCount(new LambdaQueryWrapper<LotFans>()
  880. .eq(LotFans::getLotId, lot.getId())
  881. .eq(LotFans::getUserId, userInfo.getId().longValue())
  882. .eq(LotFans::getType, "user_like"));
  883. response.setIsFans(favoriteCount > 0);
  884. LambdaQueryWrapper<DepositOrder> depositQuery = new LambdaQueryWrapper<DepositOrder>()
  885. .eq(DepositOrder::getUserId, userInfo.getId())
  886. .in(DepositOrder::getStatus, 1);
  887. if (Objects.equals("LOT", depositType)) {
  888. depositQuery.eq(DepositOrder::getLotId, lot.getId())
  889. .eq(DepositOrder::getDepositType, "拍品");
  890. } else {
  891. depositQuery.eq(DepositOrder::getAuctionId, lot.getAuctionId())
  892. .eq(DepositOrder::getDepositType, "拍卖会");
  893. }
  894. Long depositCount = depositOrderMapper.selectCount(depositQuery);
  895. response.setHasDeposit(depositCount > 0);
  896. }
  897. @Override
  898. public List<LotExportDTO> exportLotList(LotRequest request) {
  899. if (Objects.isNull(request.getPageNum()) && Objects.isNull(request.getPageSize())) {
  900. request.setPageNum(1);
  901. request.setPageSize(1000);
  902. }
  903. request.setDelFlag(Constants.DEL_FLAG_NO_DELETE);
  904. IPage<Lot> lotIPage=new Page<>(request.getPageNum(),request.getPageSize());
  905. List<Lot> lotList = lotMapper.selectLotList(lotIPage, request);
  906. List<LotExportDTO> lotExportDTOS = lotList.stream().map(l -> {
  907. LotExportDTO lotExportDTO = new LotExportDTO();
  908. lotExportDTO.setId(String.valueOf(l.getId()));
  909. lotExportDTO.setGoodsId(l.getGoodsId());
  910. lotExportDTO.setGoodsName(l.getGoodsName());
  911. lotExportDTO.setGoodsType(l.getGoodsType());
  912. lotExportDTO.setSort(String.valueOf(l.getSort()));
  913. lotExportDTO.setBidCount(String.valueOf(l.getBidCount()));
  914. lotExportDTO.setPubStatus(PubStatusEnum.of(l.getPubStatus()).getDesc());
  915. lotExportDTO.setStatus(LotStatusEnum.of(l.getStatus()).getDesc());
  916. lotExportDTO.setCreateTime(DateUtils.parseDateToStr(l.getCreateTime()));
  917. lotExportDTO.setStartTime(DateUtils.parseDateToStr(l.getStartTime()));
  918. lotExportDTO.setEndTime(DateUtils.parseDateToStr(l.getEndTime()));
  919. lotExportDTO.setDeposit(String.valueOf(l.getDeposit() == null ? 0 : l.getDeposit()));
  920. lotExportDTO.setServiceTariff(String.valueOf(l.getServiceTariff()));
  921. lotExportDTO.setRuleType(RuleTypeEnum.getByCode(l.getRuleType()).getDesc());
  922. // 起拍价
  923. if (StringUtils.isNotEmpty(l.getRuleContent())) {
  924. TraditionRule traditionRule = JSON.parseObject(l.getRuleContent(), TraditionRule.class);
  925. lotExportDTO.setLastPrice(String.valueOf(traditionRule.getStartPrice()));
  926. }
  927. return lotExportDTO;
  928. }).collect(Collectors.toList());
  929. return lotExportDTOS;
  930. }
  931. @Override
  932. public List<Lot> selectLotListByLotIds(List<Long> lotIds) {
  933. return baseMapper.selectLotListByLotIds(lotIds);
  934. }
  935. }