### Question:
OrderServiceImpl implements OrderService { @Override @Transactional public OrderDTO create(OrderDTO orderDTO) { String orderId = KeyUtil.genUniqueKey(); BigDecimal orderAmount = new BigDecimal(BigInteger.ZERO); for(OrderDetail orderDetail : orderDTO.getOrderDetailList()){ Optional<ProductInfo> productInfo = productService.findById(orderDetail.getProductId()); if(!productInfo.isPresent() ){ throw new SellException(ResultEnum.PRODUCT_NOT_EXIST); } orderAmount = productInfo.get().getProductPrice() .multiply(new BigDecimal(orderDetail.getProductQuantity())) .add(orderAmount); orderDetail.setDetailId(KeyUtil.genUniqueKey()); orderDetail.setOrderId(orderId); BeanUtils.copyProperties(productInfo.get() , orderDetail); orderDetailRepository.save(orderDetail); } OrderMaster orderMaster = new OrderMaster(); orderDTO.setOrderId(orderId); BeanUtils.copyProperties(orderDTO , orderMaster); orderMaster.setOrderAmount(orderAmount); orderMaster.setOrderStatus(OrderStatusEnum.NEW_PAYED.getCode()); orderMaster.setPayStatus(PayStatusEnum.SUCCESS.getCode()); orderMasterRepository.save(orderMaster); List<CartDTO> cartDTOList = orderDTO.getOrderDetailList().stream().map(e -> new CartDTO(e.getProductId() , e.getProductQuantity())) .collect(Collectors.toList()); productService.decreaseStock(cartDTOList); webSocket.sendMessage(orderDTO.getOrderId()); return orderDTO; }  @Override @Transactional OrderDTO create(OrderDTO orderDTO); @Override OrderDTO findOne(String orderId); @Override Page<OrderDTO> findList(String buyerOpenid, Pageable pageable); @Override Page<OrderDTO> findList(Pageable pageable); @Override Page<OrderDTO> findOrderMastersByCreateTimeDesc(Pageable pageable); @Override List<OrderDTO> findListStats(String buyerOpenid, Integer orderStatus); @Override @Transactional OrderDTO cancel(OrderDTO orderDTO); @Override @Transactional OrderDTO finish(OrderDTO orderDTO); @Override @Transactional OrderDTO paid(OrderDTO orderDTO);  }### Answer:
@Test public void create() { OrderDTO orderDTO = new OrderDTO(); orderDTO.setBuyerName("小芳"); orderDTO.setBuyerAddress("嘉应学院"); orderDTO.setBuyerPhone("12345678910"); orderDTO.setBuyerOpenid(BUYER_OPENID); List<OrderDetail> orderDetailList = new ArrayList<>(); OrderDetail o1 = new OrderDetail(); o1.setProductId("123456"); o1.setProductQuantity(1); orderDetailList.add(o1); OrderDetail o2 = new OrderDetail(); o2.setProductId("111"); o2.setProductQuantity(1); orderDetailList.add(o2); orderDTO.setOrderDetailList(orderDetailList); OrderDTO result = orderService.create(orderDTO); log.info("【创建订单】 result={}",result); Assert.assertNotNull(result); }