@Test public void testDemo2() throws Exception { }
public Map<String, Object> demo2(Long commodityId) { List<Map<String, Object>> mapList = new ArrayList<>(); Map<String, Object> map = new HashMap<>(); Commodity commoditys = commMapper.selectByPrimaryKey(commodityId); CommodityTemplate template = templateMapper.selectByPrimaryKey(commoditys.getTempId()); Integer num = template.getCardNum(); Integer money = template.getCardMoney(); Integer type = template.getCardType(); List<Card> list = cardMapper.selectByCommodityId(commodityId); if (list == null || list.size() == 0) { Card card = new Card(); card.setState(0); card.setCorporation(type); card.setCommodityId(0l); card.setMoney(money); List<Card> cards = cardMapper.select(card); if (cards.size() >= num) { map.put("size", num); for (int i = 0; i < num; i++) { Map<String, Object> map1 = new HashMap<>(); map1.put("cardNumber", cards.get(i).getCardNum()); map1.put("password", null); map1.put("state", cards.get(i).getState()); mapList.add(map1); cardMapper.updateCardState(cards.get(i).getCardNum(), commodityId); } map.put("cardNumberList", mapList); map.put("worth", money); } else { map.put("size", 0); map.put("cardNumberList", new ArrayList<>()); map.put("worth", 0); } } else { map.put("size", num); for (Card card : list) { Map<String, Object> map1 = new HashMap<>(); map1.put("cardNumber", card.getCardNum()); map1.put("password", card.getPassword()); map1.put("state", card.getState()); mapList.add(map1); } map.put("cardNumberList", mapList); map.put("worth", money); } return map; }
ExchangeMethodServiceImpl implements IExchangeMethodService { public Map<String, Object> demo2(Long commodityId) { List<Map<String, Object>> mapList = new ArrayList<>(); Map<String, Object> map = new HashMap<>(); Commodity commoditys = commMapper.selectByPrimaryKey(commodityId); CommodityTemplate template = templateMapper.selectByPrimaryKey(commoditys.getTempId()); Integer num = template.getCardNum(); Integer money = template.getCardMoney(); Integer type = template.getCardType(); List<Card> list = cardMapper.selectByCommodityId(commodityId); if (list == null || list.size() == 0) { Card card = new Card(); card.setState(0); card.setCorporation(type); card.setCommodityId(0l); card.setMoney(money); List<Card> cards = cardMapper.select(card); if (cards.size() >= num) { map.put("size", num); for (int i = 0; i < num; i++) { Map<String, Object> map1 = new HashMap<>(); map1.put("cardNumber", cards.get(i).getCardNum()); map1.put("password", null); map1.put("state", cards.get(i).getState()); mapList.add(map1); cardMapper.updateCardState(cards.get(i).getCardNum(), commodityId); } map.put("cardNumberList", mapList); map.put("worth", money); } else { map.put("size", 0); map.put("cardNumberList", new ArrayList<>()); map.put("worth", 0); } } else { map.put("size", num); for (Card card : list) { Map<String, Object> map1 = new HashMap<>(); map1.put("cardNumber", card.getCardNum()); map1.put("password", card.getPassword()); map1.put("state", card.getState()); mapList.add(map1); } map.put("cardNumberList", mapList); map.put("worth", money); } return map; } }
ExchangeMethodServiceImpl implements IExchangeMethodService { public Map<String, Object> demo2(Long commodityId) { List<Map<String, Object>> mapList = new ArrayList<>(); Map<String, Object> map = new HashMap<>(); Commodity commoditys = commMapper.selectByPrimaryKey(commodityId); CommodityTemplate template = templateMapper.selectByPrimaryKey(commoditys.getTempId()); Integer num = template.getCardNum(); Integer money = template.getCardMoney(); Integer type = template.getCardType(); List<Card> list = cardMapper.selectByCommodityId(commodityId); if (list == null || list.size() == 0) { Card card = new Card(); card.setState(0); card.setCorporation(type); card.setCommodityId(0l); card.setMoney(money); List<Card> cards = cardMapper.select(card); if (cards.size() >= num) { map.put("size", num); for (int i = 0; i < num; i++) { Map<String, Object> map1 = new HashMap<>(); map1.put("cardNumber", cards.get(i).getCardNum()); map1.put("password", null); map1.put("state", cards.get(i).getState()); mapList.add(map1); cardMapper.updateCardState(cards.get(i).getCardNum(), commodityId); } map.put("cardNumberList", mapList); map.put("worth", money); } else { map.put("size", 0); map.put("cardNumberList", new ArrayList<>()); map.put("worth", 0); } } else { map.put("size", num); for (Card card : list) { Map<String, Object> map1 = new HashMap<>(); map1.put("cardNumber", card.getCardNum()); map1.put("password", card.getPassword()); map1.put("state", card.getState()); mapList.add(map1); } map.put("cardNumberList", mapList); map.put("worth", money); } return map; }  }
ExchangeMethodServiceImpl implements IExchangeMethodService { public Map<String, Object> demo2(Long commodityId) { List<Map<String, Object>> mapList = new ArrayList<>(); Map<String, Object> map = new HashMap<>(); Commodity commoditys = commMapper.selectByPrimaryKey(commodityId); CommodityTemplate template = templateMapper.selectByPrimaryKey(commoditys.getTempId()); Integer num = template.getCardNum(); Integer money = template.getCardMoney(); Integer type = template.getCardType(); List<Card> list = cardMapper.selectByCommodityId(commodityId); if (list == null || list.size() == 0) { Card card = new Card(); card.setState(0); card.setCorporation(type); card.setCommodityId(0l); card.setMoney(money); List<Card> cards = cardMapper.select(card); if (cards.size() >= num) { map.put("size", num); for (int i = 0; i < num; i++) { Map<String, Object> map1 = new HashMap<>(); map1.put("cardNumber", cards.get(i).getCardNum()); map1.put("password", null); map1.put("state", cards.get(i).getState()); mapList.add(map1); cardMapper.updateCardState(cards.get(i).getCardNum(), commodityId); } map.put("cardNumberList", mapList); map.put("worth", money); } else { map.put("size", 0); map.put("cardNumberList", new ArrayList<>()); map.put("worth", 0); } } else { map.put("size", num); for (Card card : list) { Map<String, Object> map1 = new HashMap<>(); map1.put("cardNumber", card.getCardNum()); map1.put("password", card.getPassword()); map1.put("state", card.getState()); mapList.add(map1); } map.put("cardNumberList", mapList); map.put("worth", money); } return map; }  @Override boolean exchangeToCash(String exchangeTerraceName, String terraceAccount, Long commodityId, Long accountId); @Override List<Map<String, Object>> selectUserRechargeCardPrize(Long accountId, Long commodityId); @Override boolean orTrue(Long accountId, Long commodityId); @Override Map<String, Object> selectUserRechargeCardExchangeProcess(Long accountId, Long commodityId); Map<String, Object> demo2(Long commodityId); Map<String, Object> demo3(Long accountId, Long commodityId); @Override Map<String, Object> temp1(Long accountId, Long commodityId); @Override Map<String, Object> temp2(Long accountId, Long commodityId, Long addressId); @Override Map<String, Object> temp3(Long accountId, Long commodityId); @Override boolean temp4(Long accountId, Long commodityId); @Override Map<String, Object> temp5(Long accountId, Long commodityId); @Override String cardPassword(String card); }
ExchangeMethodServiceImpl implements IExchangeMethodService { public Map<String, Object> demo2(Long commodityId) { List<Map<String, Object>> mapList = new ArrayList<>(); Map<String, Object> map = new HashMap<>(); Commodity commoditys = commMapper.selectByPrimaryKey(commodityId); CommodityTemplate template = templateMapper.selectByPrimaryKey(commoditys.getTempId()); Integer num = template.getCardNum(); Integer money = template.getCardMoney(); Integer type = template.getCardType(); List<Card> list = cardMapper.selectByCommodityId(commodityId); if (list == null || list.size() == 0) { Card card = new Card(); card.setState(0); card.setCorporation(type); card.setCommodityId(0l); card.setMoney(money); List<Card> cards = cardMapper.select(card); if (cards.size() >= num) { map.put("size", num); for (int i = 0; i < num; i++) { Map<String, Object> map1 = new HashMap<>(); map1.put("cardNumber", cards.get(i).getCardNum()); map1.put("password", null); map1.put("state", cards.get(i).getState()); mapList.add(map1); cardMapper.updateCardState(cards.get(i).getCardNum(), commodityId); } map.put("cardNumberList", mapList); map.put("worth", money); } else { map.put("size", 0); map.put("cardNumberList", new ArrayList<>()); map.put("worth", 0); } } else { map.put("size", num); for (Card card : list) { Map<String, Object> map1 = new HashMap<>(); map1.put("cardNumber", card.getCardNum()); map1.put("password", card.getPassword()); map1.put("state", card.getState()); mapList.add(map1); } map.put("cardNumberList", mapList); map.put("worth", money); } return map; }  @Override boolean exchangeToCash(String exchangeTerraceName, String terraceAccount, Long commodityId, Long accountId); @Override List<Map<String, Object>> selectUserRechargeCardPrize(Long accountId, Long commodityId); @Override boolean orTrue(Long accountId, Long commodityId); @Override Map<String, Object> selectUserRechargeCardExchangeProcess(Long accountId, Long commodityId); Map<String, Object> demo2(Long commodityId); Map<String, Object> demo3(Long accountId, Long commodityId); @Override Map<String, Object> temp1(Long accountId, Long commodityId); @Override Map<String, Object> temp2(Long accountId, Long commodityId, Long addressId); @Override Map<String, Object> temp3(Long accountId, Long commodityId); @Override boolean temp4(Long accountId, Long commodityId); @Override Map<String, Object> temp5(Long accountId, Long commodityId); @Override String cardPassword(String card);  }