public void payServiceTest() { Worker worker = workerDAO.getWorkerById(7); Order order = orderDAO.getOrderById(8); Bankcard bankcard = bankcardDAO.getCardById(2); PayStatus status = payService.payForOrder(order, worker, bankcard); System.out.println(status.toString()); }
public static Customer addOrdersFromDB(Customer c) { Customer newCustomer = new Customer(c.getID()); List<Order> orders = orderDAO.retrieveOrders(c); for (Order o : orders) { newCustomer.addOrder(o); } return newCustomer; }
/** Method to test Order domain object. */ @Rollback(false) @Test public void Order() { Order instance = new Order(); // Test create // TODO: Populate instance for create. The store will fail if the primary key fields are blank. // store the object dataStore.store(instance); // Test update // TODO: Modify non-key domain object values for update // update the object dataStore.store(instance); // Test delete dataStore.remove(instance); }
public static void addOrderToDB(Order o) { Customer customer = CustomerServiceImpl.getCustomer(o.getCustomerID()); customer.setOrders(OrderServiceImpl.retrieveUnpaidOrders(customer)); customer.addOrder(o); if (customer.getOrders().contains(o)) { orderDAO.addOrder(o); List<OrderItem> items = o.getItems(); Inventory inventory = new Inventory(InventoryServiceImpl.getAllAvailableProductsInDB()); for (OrderItem i : items) { Product product = ProductServiceImpl.getProduct(i.getItemSKUNumber()); InventoryItem inventoryitem = InventoryServiceImpl.getInventoryItem(inventory, product); InventoryServiceImpl.deductFromInventory(inventory, inventoryitem, i.getQuantity()); } } }
public void orderTest() { Customer customer = customerDAO.getCustomerById(3); List<Commodity> commodityList = commoDAO.getCommoditiesByIdString("2;3;4"); List<OrderCommodityRel> relationLsit = CommodityListTools.commoToRel(commodityList); Order order = new Order(customer, relationLsit, 100); Map<Integer, Integer> map = new HashMap<Integer, Integer>(); map.put(2, 2); map.put(3, 4); map.put(4, 4); order.setBuyNum(map); Date date = new Date(); order.setOrderTime(new Timestamp(date.getTime())); orderDAO.createOrder(order); System.out.println(order.getOrderId()); }
public void processOrder(Order orderInfo) throws ProcessingException, InvalidAddressException { // Validate Order information if (orderInfo == null || orderInfo.getAddress() == null) { throw new ProcessingException("Mandatory info not found"); } if (orderInfo.getAddress() != null) { // Our services are currently only in CA if (!("CA".equals(orderInfo.getAddress().getState()))) { throw new ProcessingException("We currently process only CA orders"); } } // Validate Address Info get address id call third party address // validation service long addressId = addressValidator.validateAddress(orderInfo.getAddress()); if (addressId == -1) { throw new InvalidAddressException(); } // Call Feasibility service to check if line is feasible at this address // ( pass the address id) FeasibilityInfo feasibiliyInfo = null; try { feasibiliyInfo = feasibilityService.checkFeasibility(addressId); } catch (FeasibilityException e) { // Log the error throw new ProcessingException("Order cannot be fulfilled"); } // Check for promotions for the order // Apply Promotions if any OrderDBObject orderDBObject = transformOrderInfoToOrderDAO(orderInfo, feasibiliyInfo); // Process the order ( persist db entries) String orderId; try { orderId = orderDao.insertOrder(orderDBObject); } catch (Exception e) { throw new ProcessingException("Error submitting order"); } NotificationVO notificationVO = new NotificationVO(); notificationVO.setMessageType("EMAIL"); notificationVO.setMessageBody("Order ID" + orderId + "Submitted for processing "); notificationService.sendNotification(notificationVO); }
/** * @param task * @throws SQLException */ public long add(Task task) throws SQLException { String insertSQL = "insert into " + TABLE_NAME + "(ID,NAME,STATUS,CTIME,FTIME,MESSAGE,TYPE) values(?,?,?,?,?,?,?)"; ; Connection conn = null; PreparedStatement inStmt = null; boolean autoCommit = false; try { conn = DBUtil.getConnection(); autoCommit = conn.getAutoCommit(); conn.setAutoCommit(false); inStmt = conn.prepareStatement(insertSQL); inStmt.setLong(1, task.getId()); inStmt.setString(2, task.getName()); inStmt.setInt(3, task.getStatus()); inStmt.setLong(4, task.getcTime()); inStmt.setLong(5, task.getfTime()); inStmt.setString(6, task.getMessage()); inStmt.setString(7, task.getType()); inStmt.execute(); orderDAO.add(conn, task.getOrders()); conn.commit(); return task.getId(); } catch (Exception e) { LOG.error("Will rollback"); conn.rollback(); LOG.error(e.getMessage(), e); throw new RuntimeException(e); } finally { if (conn != null) { conn.setAutoCommit(autoCommit); conn.close(); } if (inStmt != null) { inStmt.close(); } } }
public void paymentTest() { Payment payment = new Payment(); // 取出订单 Order order = orderDAO.getOrderById(8); // 取出订单顾客 Customer customer = order.getCustomer(); // 取出操作员 Worker worker = workerDAO.getWorkerById(7); // 取出银行卡 Bankcard bankcard = customer.getBankcardList().get(0); payment.setPayCustomer(customer); System.out.println("OrderId:" + order.getOrderId()); payment.setPayOrder(order); System.out.println(bankcard); payment.setPayCard(bankcard); payment.setPayPrice(order.getOrderPrice()); payment.setPayType(1); payment.setWorker(worker); paymentDAO.createPayment(payment); }
public static List<Order> retrieveUnpaidOrders(Customer customer) { List<Order> orders = orderDAO.retrieveUnpaidOrders(customer.getID()); return orders; }
public List<Order> retrieveOrdersFromDB(Customer c) { return orderDAO.retrieveOrders(c); }
public static Order retrieveOrderFromDB(int orderNumber) { return orderDAO.retrieveOrder(orderNumber); }
public static void updateStatusOfOrderInDB(Order o) { orderDAO.payOrder(o); }
public static int getLastOrderNumber() { return orderDAO.getLastOrderNumber(); }