@Test public void testSelectCommodity() throws Exception { }
@Override public Map<String, Object> selectCommodity(User user, Long commodId) { Commoditys com = commsMapper.selectByKey(commodId); if (null == com) return null; commMapper.updateViewNum(commodId, com.getViewNum() + 1); Map<String, Object> map = new HashMap<>(); String nextRound = null; Long nextRoundId = null; if (com.getStateId() == 3 || com.getStateId() == 2) { Commoditys comh = null; List<Long> longs = commMapper.selectBefore(com.getTempId(), com.getId()); if (longs.size() != 0) { comh = commsMapper.selectByKey(longs.get(0)); } if (comh == null) { map.put("beforeLottery", new HashMap<>()); } else if (com.getStateId() == 3) { map.put("beforeLottery", mapBefore(comh)); } } if (com.getStateId() == 2) { List<Commoditys> commsList = commsMapper.selectNextRoundComm(com.getTempId(), Settings.COMMODITY_STATE_ON_SALE); if (!commsList.isEmpty()) { Commoditys commoditys = commsList.get(0); nextRound = commoditys.getRoundTime() + "期正在火热进行中"; nextRoundId = commoditys.getId(); } } if (com.getStateId() == 1) { Commoditys byKey = commsMapper.selectByKey(commodId); map.put("beforeLottery", mapBefore(byKey)); List<Commoditys> commsList = commsMapper.selectNextRoundComm(com.getTempId(), Settings.COMMODITY_STATE_ON_SALE); if (!commsList.isEmpty()) { Commoditys commoditys = commsList.get(0); nextRound = commoditys.getRoundTime() + "期正在火热进行中"; nextRoundId = commoditys.getId(); } } String msg = "0"; if (null != user) { Integer amount1 = luckCodeMapper.countUserCommAmount(user.getAccountId(), commodId); Integer amount2 = userHistoryMapper.countHistoryUserCommAmount(user.getAccountId(), commodId); msg = amount1 + amount2 + ""; } map.put("user", msg); map.put("nextRound", nextRound); map.put("nextRoundId", nextRoundId); map.put("commId", commodId); map.put("minNum", com.getMinimum()); map.put("coverImg", com.getCoverImgUrl()); map.put("imgUrls", listUrl(commodId)); map.put("onState", com.getStateId()); map.put("commodityName", com.getName()); map.put("buyTotal", com.getBuyTotalNumber()); map.put("buyCurrent", com.getBuyTotalNumber() - com.getBuyCurrentNumber()); map.put("roundTime", com.getRoundTime()); map.put("countDown", ServiceUtils.getResidualLotterySeconds(com)); map.put("descUrl", com.getCommodityDescUrl()); map.put("partake", listPartake(commodId)); map.put("guessLike", listMap3()); return map; }
CommodityServiceImpl implements ICommodityService { @Override public Map<String, Object> selectCommodity(User user, Long commodId) { Commoditys com = commsMapper.selectByKey(commodId); if (null == com) return null; commMapper.updateViewNum(commodId, com.getViewNum() + 1); Map<String, Object> map = new HashMap<>(); String nextRound = null; Long nextRoundId = null; if (com.getStateId() == 3 || com.getStateId() == 2) { Commoditys comh = null; List<Long> longs = commMapper.selectBefore(com.getTempId(), com.getId()); if (longs.size() != 0) { comh = commsMapper.selectByKey(longs.get(0)); } if (comh == null) { map.put("beforeLottery", new HashMap<>()); } else if (com.getStateId() == 3) { map.put("beforeLottery", mapBefore(comh)); } } if (com.getStateId() == 2) { List<Commoditys> commsList = commsMapper.selectNextRoundComm(com.getTempId(), Settings.COMMODITY_STATE_ON_SALE); if (!commsList.isEmpty()) { Commoditys commoditys = commsList.get(0); nextRound = commoditys.getRoundTime() + "期正在火热进行中"; nextRoundId = commoditys.getId(); } } if (com.getStateId() == 1) { Commoditys byKey = commsMapper.selectByKey(commodId); map.put("beforeLottery", mapBefore(byKey)); List<Commoditys> commsList = commsMapper.selectNextRoundComm(com.getTempId(), Settings.COMMODITY_STATE_ON_SALE); if (!commsList.isEmpty()) { Commoditys commoditys = commsList.get(0); nextRound = commoditys.getRoundTime() + "期正在火热进行中"; nextRoundId = commoditys.getId(); } } String msg = "0"; if (null != user) { Integer amount1 = luckCodeMapper.countUserCommAmount(user.getAccountId(), commodId); Integer amount2 = userHistoryMapper.countHistoryUserCommAmount(user.getAccountId(), commodId); msg = amount1 + amount2 + ""; } map.put("user", msg); map.put("nextRound", nextRound); map.put("nextRoundId", nextRoundId); map.put("commId", commodId); map.put("minNum", com.getMinimum()); map.put("coverImg", com.getCoverImgUrl()); map.put("imgUrls", listUrl(commodId)); map.put("onState", com.getStateId()); map.put("commodityName", com.getName()); map.put("buyTotal", com.getBuyTotalNumber()); map.put("buyCurrent", com.getBuyTotalNumber() - com.getBuyCurrentNumber()); map.put("roundTime", com.getRoundTime()); map.put("countDown", ServiceUtils.getResidualLotterySeconds(com)); map.put("descUrl", com.getCommodityDescUrl()); map.put("partake", listPartake(commodId)); map.put("guessLike", listMap3()); return map; } }
CommodityServiceImpl implements ICommodityService { @Override public Map<String, Object> selectCommodity(User user, Long commodId) { Commoditys com = commsMapper.selectByKey(commodId); if (null == com) return null; commMapper.updateViewNum(commodId, com.getViewNum() + 1); Map<String, Object> map = new HashMap<>(); String nextRound = null; Long nextRoundId = null; if (com.getStateId() == 3 || com.getStateId() == 2) { Commoditys comh = null; List<Long> longs = commMapper.selectBefore(com.getTempId(), com.getId()); if (longs.size() != 0) { comh = commsMapper.selectByKey(longs.get(0)); } if (comh == null) { map.put("beforeLottery", new HashMap<>()); } else if (com.getStateId() == 3) { map.put("beforeLottery", mapBefore(comh)); } } if (com.getStateId() == 2) { List<Commoditys> commsList = commsMapper.selectNextRoundComm(com.getTempId(), Settings.COMMODITY_STATE_ON_SALE); if (!commsList.isEmpty()) { Commoditys commoditys = commsList.get(0); nextRound = commoditys.getRoundTime() + "期正在火热进行中"; nextRoundId = commoditys.getId(); } } if (com.getStateId() == 1) { Commoditys byKey = commsMapper.selectByKey(commodId); map.put("beforeLottery", mapBefore(byKey)); List<Commoditys> commsList = commsMapper.selectNextRoundComm(com.getTempId(), Settings.COMMODITY_STATE_ON_SALE); if (!commsList.isEmpty()) { Commoditys commoditys = commsList.get(0); nextRound = commoditys.getRoundTime() + "期正在火热进行中"; nextRoundId = commoditys.getId(); } } String msg = "0"; if (null != user) { Integer amount1 = luckCodeMapper.countUserCommAmount(user.getAccountId(), commodId); Integer amount2 = userHistoryMapper.countHistoryUserCommAmount(user.getAccountId(), commodId); msg = amount1 + amount2 + ""; } map.put("user", msg); map.put("nextRound", nextRound); map.put("nextRoundId", nextRoundId); map.put("commId", commodId); map.put("minNum", com.getMinimum()); map.put("coverImg", com.getCoverImgUrl()); map.put("imgUrls", listUrl(commodId)); map.put("onState", com.getStateId()); map.put("commodityName", com.getName()); map.put("buyTotal", com.getBuyTotalNumber()); map.put("buyCurrent", com.getBuyTotalNumber() - com.getBuyCurrentNumber()); map.put("roundTime", com.getRoundTime()); map.put("countDown", ServiceUtils.getResidualLotterySeconds(com)); map.put("descUrl", com.getCommodityDescUrl()); map.put("partake", listPartake(commodId)); map.put("guessLike", listMap3()); return map; }  }
CommodityServiceImpl implements ICommodityService { @Override public Map<String, Object> selectCommodity(User user, Long commodId) { Commoditys com = commsMapper.selectByKey(commodId); if (null == com) return null; commMapper.updateViewNum(commodId, com.getViewNum() + 1); Map<String, Object> map = new HashMap<>(); String nextRound = null; Long nextRoundId = null; if (com.getStateId() == 3 || com.getStateId() == 2) { Commoditys comh = null; List<Long> longs = commMapper.selectBefore(com.getTempId(), com.getId()); if (longs.size() != 0) { comh = commsMapper.selectByKey(longs.get(0)); } if (comh == null) { map.put("beforeLottery", new HashMap<>()); } else if (com.getStateId() == 3) { map.put("beforeLottery", mapBefore(comh)); } } if (com.getStateId() == 2) { List<Commoditys> commsList = commsMapper.selectNextRoundComm(com.getTempId(), Settings.COMMODITY_STATE_ON_SALE); if (!commsList.isEmpty()) { Commoditys commoditys = commsList.get(0); nextRound = commoditys.getRoundTime() + "期正在火热进行中"; nextRoundId = commoditys.getId(); } } if (com.getStateId() == 1) { Commoditys byKey = commsMapper.selectByKey(commodId); map.put("beforeLottery", mapBefore(byKey)); List<Commoditys> commsList = commsMapper.selectNextRoundComm(com.getTempId(), Settings.COMMODITY_STATE_ON_SALE); if (!commsList.isEmpty()) { Commoditys commoditys = commsList.get(0); nextRound = commoditys.getRoundTime() + "期正在火热进行中"; nextRoundId = commoditys.getId(); } } String msg = "0"; if (null != user) { Integer amount1 = luckCodeMapper.countUserCommAmount(user.getAccountId(), commodId); Integer amount2 = userHistoryMapper.countHistoryUserCommAmount(user.getAccountId(), commodId); msg = amount1 + amount2 + ""; } map.put("user", msg); map.put("nextRound", nextRound); map.put("nextRoundId", nextRoundId); map.put("commId", commodId); map.put("minNum", com.getMinimum()); map.put("coverImg", com.getCoverImgUrl()); map.put("imgUrls", listUrl(commodId)); map.put("onState", com.getStateId()); map.put("commodityName", com.getName()); map.put("buyTotal", com.getBuyTotalNumber()); map.put("buyCurrent", com.getBuyTotalNumber() - com.getBuyCurrentNumber()); map.put("roundTime", com.getRoundTime()); map.put("countDown", ServiceUtils.getResidualLotterySeconds(com)); map.put("descUrl", com.getCommodityDescUrl()); map.put("partake", listPartake(commodId)); map.put("guessLike", listMap3()); return map; }  @Override boolean addCommodity(Commoditys commod); @Override boolean delete(Long id); @Override Commoditys selectByid(Long id); @Override List<Commoditys> selectTypeAll(String commodType); @Override int selectCount(Integer commodityTypeId); @Override List<Commoditys> selectAll(); @Override List<Map<String, Object>> selectByStyle(Integer type, Long lastCommId); @Override List<Map<String, Object>> selectOnLottery(Integer page); @Override List<Map<String, Object>> selectOneOnLottery(Long commId); @Override Map<String, Object> selectCommodity(User user, Long commodId); List<Map<String, Object>> listMap3(); List<String> listUrl(Long commodId); Map<String, Object> mapBefore(Commoditys comh); List<Map<String, Object>> listPartake(Long commodId); Map<String, Object> map1(Long userAccountId); Map<String, Object> map2(Long commodId, Long userAccountId); @Override List<Map<String, Object>> selectPaging(Integer categoryId, String commName, Long lastCommId); List<Map<String, Object>> type1(Integer categoryId, String commName, Long lastCommId); List<Map<String, Object>> byType(Integer categoryId, Long lastCommId); List<Map<String, Object>> type4(String commName, Long lastCommId); List<Map<String, Object>> forPut(List<Commoditys> list); @Override List<Map<String, Object>> selectHeight(Long lastCommId); @Override Long generateNewRoundTime(); @Override List<Map<String, Object>> selectNewestAnnounceComm(Long lastCommId); @Override List<Map> selectThePastAnnouncedCommList(Long commId); @Override String getContent(Long commodityId); @Override long getMaxRoundTime(); @Override List<CommodityTemplate> getNotKeepRoundTemplate(long roundNum); @Override Commodity getNextCommodity(Long id); @Override Commodity groundNext(Long id); @Override Commoditys getDetails(Long id); @Override Commoditys selectOnSellCommodities(Long id); @Override List<CommodityAmount> selectAmounts(Long orderId); }
CommodityServiceImpl implements ICommodityService { @Override public Map<String, Object> selectCommodity(User user, Long commodId) { Commoditys com = commsMapper.selectByKey(commodId); if (null == com) return null; commMapper.updateViewNum(commodId, com.getViewNum() + 1); Map<String, Object> map = new HashMap<>(); String nextRound = null; Long nextRoundId = null; if (com.getStateId() == 3 || com.getStateId() == 2) { Commoditys comh = null; List<Long> longs = commMapper.selectBefore(com.getTempId(), com.getId()); if (longs.size() != 0) { comh = commsMapper.selectByKey(longs.get(0)); } if (comh == null) { map.put("beforeLottery", new HashMap<>()); } else if (com.getStateId() == 3) { map.put("beforeLottery", mapBefore(comh)); } } if (com.getStateId() == 2) { List<Commoditys> commsList = commsMapper.selectNextRoundComm(com.getTempId(), Settings.COMMODITY_STATE_ON_SALE); if (!commsList.isEmpty()) { Commoditys commoditys = commsList.get(0); nextRound = commoditys.getRoundTime() + "期正在火热进行中"; nextRoundId = commoditys.getId(); } } if (com.getStateId() == 1) { Commoditys byKey = commsMapper.selectByKey(commodId); map.put("beforeLottery", mapBefore(byKey)); List<Commoditys> commsList = commsMapper.selectNextRoundComm(com.getTempId(), Settings.COMMODITY_STATE_ON_SALE); if (!commsList.isEmpty()) { Commoditys commoditys = commsList.get(0); nextRound = commoditys.getRoundTime() + "期正在火热进行中"; nextRoundId = commoditys.getId(); } } String msg = "0"; if (null != user) { Integer amount1 = luckCodeMapper.countUserCommAmount(user.getAccountId(), commodId); Integer amount2 = userHistoryMapper.countHistoryUserCommAmount(user.getAccountId(), commodId); msg = amount1 + amount2 + ""; } map.put("user", msg); map.put("nextRound", nextRound); map.put("nextRoundId", nextRoundId); map.put("commId", commodId); map.put("minNum", com.getMinimum()); map.put("coverImg", com.getCoverImgUrl()); map.put("imgUrls", listUrl(commodId)); map.put("onState", com.getStateId()); map.put("commodityName", com.getName()); map.put("buyTotal", com.getBuyTotalNumber()); map.put("buyCurrent", com.getBuyTotalNumber() - com.getBuyCurrentNumber()); map.put("roundTime", com.getRoundTime()); map.put("countDown", ServiceUtils.getResidualLotterySeconds(com)); map.put("descUrl", com.getCommodityDescUrl()); map.put("partake", listPartake(commodId)); map.put("guessLike", listMap3()); return map; }  @Override boolean addCommodity(Commoditys commod); @Override boolean delete(Long id); @Override Commoditys selectByid(Long id); @Override List<Commoditys> selectTypeAll(String commodType); @Override int selectCount(Integer commodityTypeId); @Override List<Commoditys> selectAll(); @Override List<Map<String, Object>> selectByStyle(Integer type, Long lastCommId); @Override List<Map<String, Object>> selectOnLottery(Integer page); @Override List<Map<String, Object>> selectOneOnLottery(Long commId); @Override Map<String, Object> selectCommodity(User user, Long commodId); List<Map<String, Object>> listMap3(); List<String> listUrl(Long commodId); Map<String, Object> mapBefore(Commoditys comh); List<Map<String, Object>> listPartake(Long commodId); Map<String, Object> map1(Long userAccountId); Map<String, Object> map2(Long commodId, Long userAccountId); @Override List<Map<String, Object>> selectPaging(Integer categoryId, String commName, Long lastCommId); List<Map<String, Object>> type1(Integer categoryId, String commName, Long lastCommId); List<Map<String, Object>> byType(Integer categoryId, Long lastCommId); List<Map<String, Object>> type4(String commName, Long lastCommId); List<Map<String, Object>> forPut(List<Commoditys> list); @Override List<Map<String, Object>> selectHeight(Long lastCommId); @Override Long generateNewRoundTime(); @Override List<Map<String, Object>> selectNewestAnnounceComm(Long lastCommId); @Override List<Map> selectThePastAnnouncedCommList(Long commId); @Override String getContent(Long commodityId); @Override long getMaxRoundTime(); @Override List<CommodityTemplate> getNotKeepRoundTemplate(long roundNum); @Override Commodity getNextCommodity(Long id); @Override Commodity groundNext(Long id); @Override Commoditys getDetails(Long id); @Override Commoditys selectOnSellCommodities(Long id); @Override List<CommodityAmount> selectAmounts(Long orderId);  }