fix: add out_of_stock to stock XML; remove invalid date_add order filter
- PrestashopClient.toStockAvailableXml: add out_of_stock=2 (use shop default) — PS 8.2.5 returns 400 code 41 without this field - PrestashopClient.getOrdersSince: remove filter[date_add] — PS 8.2.5 does not expose date_add as a filterable field for orders (400 code 32) Re-import prevention handled by OrderMapping.existsByPrestashopOrderId Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
aeec27f7af
commit
fa20b7cc91
|
|
@ -10,7 +10,6 @@ import org.springframework.web.client.RestClient;
|
|||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
|
|
@ -28,9 +27,6 @@ import java.util.Optional;
|
|||
@Component
|
||||
public class PrestashopClient {
|
||||
|
||||
private static final DateTimeFormatter PS_DATE_FORMAT =
|
||||
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
private final RestClient restClient;
|
||||
private final String wsKey;
|
||||
|
||||
|
|
@ -167,20 +163,19 @@ public class PrestashopClient {
|
|||
// ── Orders ────────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Returns orders created on or after {@code since}, with full details and order rows.
|
||||
* Returns all orders with full details and order rows.
|
||||
*
|
||||
* <p>PrestaShop date filter syntax: {@code filter[date_add]=[>=yyyy-MM-dd HH:mm:ss]}</p>
|
||||
* <p>PS 8.2.5 does not expose {@code date_add} as a filterable field for orders.
|
||||
* Re-import prevention is handled by {@code OrderMapping} in the service layer.</p>
|
||||
*
|
||||
* @param since lower bound (inclusive) for {@code date_add}
|
||||
* @param since unused — kept for API compatibility; deduplication is done via OrderMapping
|
||||
*/
|
||||
public List<PrestashopOrderDto> getOrdersSince(LocalDateTime since) {
|
||||
String dateFilter = "[>=%s]".formatted(since.format(PS_DATE_FORMAT));
|
||||
PrestashopOrderDto.ListResponse response = restClient.get()
|
||||
.uri(u -> u.path("/orders")
|
||||
.queryParam("ws_key", wsKey)
|
||||
.queryParam("output_format", "JSON")
|
||||
.queryParam("display", "full")
|
||||
.queryParam("filter[date_add]", dateFilter)
|
||||
.build())
|
||||
.retrieve()
|
||||
.body(PrestashopOrderDto.ListResponse.class);
|
||||
|
|
@ -258,6 +253,7 @@ public class PrestashopClient {
|
|||
sb.append("<id_product_attribute>").append(idAttr).append("</id_product_attribute>");
|
||||
sb.append("<quantity>").append(dto.quantity()).append("</quantity>");
|
||||
sb.append("<depends_on_stock>0</depends_on_stock>");
|
||||
sb.append("<out_of_stock>2</out_of_stock>");
|
||||
sb.append("</stock_available>");
|
||||
sb.append("</prestashop>");
|
||||
return sb.toString();
|
||||
|
|
|
|||
Loading…
Reference in New Issue