Esempio n. 1
0
 @Test
 public void insertBatchOrder() {
   List<Order> orderList = new ArrayList<Order>();
   for (int i = 0; i < 100; i++) {
     Order order = new Order();
     order.setOrderId(UUID.randomUUID().toString());
     order.setGoodsId(1);
     order.setPrice(100.0f);
     order.setPromotionPrice(80.1f);
     order.setUserId(i);
     orderList.add(order);
   }
   System.out.println(orderList.size());
   orderService.insertBatchOrder(orderList);
 }
Esempio n. 2
0
 public int addRedisDataToMysql(Map<String, String> map) {
   String id = map.get("id");
   String key = ORDERGOODS + id;
   Set<String> set = redisOperation.getSetValue(key, true);
   List<Order> list = new ArrayList<Order>();
   for (String tmp : set) {
     Order order = new Order();
     order.setGoodsId(Integer.parseInt(id));
     System.out.println("after" + UUID.randomUUID().toString());
     order.setOrderId(UUID.randomUUID().toString());
     order.setPrice(Float.parseFloat(map.get("price")));
     order.setPromotionPrice(Float.parseFloat(map.get("promotionPrice")));
     order.setUserId(Integer.parseInt(tmp));
     list.add(order);
   }
   if (list == null || list.size() == 0) {
     return 0;
   }
   return orderService.insertBatchOrder(list);
 }