mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-01-13 00:48:49 +00:00
añadidas las direcciones de pedido
This commit is contained in:
@ -446,12 +446,13 @@ public class CartService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Long crearPedido(Long cartId, Locale locale) {
|
||||
public Long crearPedido(Long cartId, Long dirFactId, Locale locale) {
|
||||
|
||||
Cart cart = this.getCartById(cartId);
|
||||
List<CartItem> items = cart.getItems();
|
||||
|
||||
List<Map<String, Object>> presupuestoRequests = new ArrayList<>();
|
||||
Map<String, Object> presupuestoDireccionesRequest = new HashMap<>();
|
||||
List<Long> presupuestoIds = new ArrayList<>();
|
||||
|
||||
for (Integer i = 0; i < items.size(); i++) {
|
||||
@ -479,6 +480,8 @@ public class CartService {
|
||||
data_to_send.put("direcciones", direcciones_presupuesto.get("direcciones"));
|
||||
data_to_send.put("direccionesFP1", direcciones_presupuesto.get("direccionesFP1"));
|
||||
|
||||
presupuestoDireccionesRequest.put(p.getId().toString(), direcciones_presupuesto);
|
||||
|
||||
Map<String, Object> result = skApiClient.savePresupuesto(data_to_send);
|
||||
|
||||
if (result.containsKey("error")) {
|
||||
@ -505,7 +508,7 @@ public class CartService {
|
||||
p.setProveedorRef2(presId);
|
||||
p.setEstado(Presupuesto.Estado.aceptado);
|
||||
presupuestoRepo.save(p);
|
||||
|
||||
|
||||
presupuestoIds.add(p.getId());
|
||||
|
||||
presupuestoRequests.add(dataMap);
|
||||
@ -526,8 +529,14 @@ public class CartService {
|
||||
if (pedidoId == null) {
|
||||
throw new IllegalStateException("No se pudo crear el pedido en SK.");
|
||||
}
|
||||
Pedido pedidoInterno = pedidoService.crearPedido(presupuestoIds, this.getCartSummaryRaw(cart, locale),
|
||||
"Safekat", String.valueOf(pedidoId), cart.getUserId());
|
||||
Pedido pedidoInterno = pedidoService.crearPedido(
|
||||
presupuestoIds,
|
||||
presupuestoDireccionesRequest,
|
||||
dirFactId,
|
||||
this.getCartSummaryRaw(cart, locale),
|
||||
"Safekat",
|
||||
String.valueOf(pedidoId),
|
||||
cart.getUserId());
|
||||
return pedidoInterno.getId();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user