use of com.salesmanager.shop.populator.order.PersistableOrderPopulator in project shopizer by shopizer-ecommerce.
the class OrderRESTController method createOrder.
/**
* This method is for adding order to the system. Generally used for the purpose of migration only
* This method won't process any payment nor create transactions
* @param store
* @param order
* @param request
* @param response
* @return
* @throws Exception
* Use v1 methods
*/
@RequestMapping(value = "/{store}/order", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
@ResponseBody
@Deprecated
public PersistableOrder createOrder(@PathVariable final String store, @Valid @RequestBody PersistableOrder order, HttpServletRequest request, HttpServletResponse response) throws Exception {
MerchantStore merchantStore = (MerchantStore) request.getAttribute(Constants.MERCHANT_STORE);
if (merchantStore != null) {
if (!merchantStore.getCode().equals(store)) {
merchantStore = null;
}
}
if (merchantStore == null) {
merchantStore = merchantStoreService.getByCode(store);
}
if (merchantStore == null) {
LOGGER.error("Merchant store is null for code " + store);
response.sendError(503, "Merchant store is null for code " + store);
return null;
}
PersistableCustomer cust = order.getCustomer();
if (cust != null) {
Customer customer = new Customer();
/* CustomerPopulator populator = new CustomerPopulator();
populator.setCountryService(countryService);
populator.setCustomerOptionService(customerOptionService);
populator.setCustomerOptionValueService(customerOptionValueService);
populator.setLanguageService(languageService);
populator.setZoneService(zoneService);
populator.setGroupService(groupService);*/
customerPopulator.populate(cust, customer, merchantStore, merchantStore.getDefaultLanguage());
customerService.save(customer);
cust.setId(customer.getId());
}
Order modelOrder = new Order();
PersistableOrderPopulator populator = new PersistableOrderPopulator();
populator.setDigitalProductService(digitalProductService);
populator.setProductAttributeService(productAttributeService);
populator.setProductService(productService);
populator.populate(order, modelOrder, merchantStore, merchantStore.getDefaultLanguage());
orderService.save(modelOrder);
order.setId(modelOrder.getId());
return order;
}
Aggregations